diff --git a/src/interfaces/Exceptions.ts b/src/interfaces/Exceptions.ts index efe6d30..af4c4c8 100644 --- a/src/interfaces/Exceptions.ts +++ b/src/interfaces/Exceptions.ts @@ -37,7 +37,6 @@ export class DependencyResolutionError extends TSinjexError { export class InjectorError extends TSinjexError { /** * Creates a new instance of {@link InjectorError} - * @param message **The error message** * @param identifier **The identifier of the dependency** * @param originalError **The original error that caused the injection error** */ @@ -65,3 +64,21 @@ export class NoInstantiationMethodError extends TSinjexError { this.name = 'TSinjexNoInstantiationMethodError'; } } + +/** + * Error class for errors during the initialization of a dependency in {@link ITSinjex}. + * @see {@link ITSinjex.inject} + */ +export class InitializationError extends TSinjexError { + /** + * Creates a new instance of {@link InitializationError} + * @param identifier **The identifier of the dependency** + * @param originalError **The original error that caused the initialization error** + */ + constructor(identifier: Identifier, originalError?: Error) { + super( + `Error initializing dependency ${identifier.toString()} with error: "${originalError}"`, + ); + this.name = 'TSinjexInitializationError'; + } +}