Improve error context for DI

This commit is contained in:
2022-08-10 21:53:56 -05:00
parent 9b47d2ac99
commit 3d836afa59
4 changed files with 60 additions and 20 deletions

View File

@@ -41,4 +41,16 @@ export abstract class AbstractFactory<T> {
* @return Collection<PropertyDependency>
*/
abstract getInjectedProperties(): Collection<PropertyDependency>
/**
* Get a human-readable name of the token this factory produces.
* This is meant for debugging output only.
*/
public getTokenName(): string {
if ( typeof this.token === 'string' ) {
return this.token
}
return this.token.name ?? '(unknown token)'
}
}