feat: Add new Error InitializationError to reflect errors during initialization of a dependency

This commit is contained in:
2024-08-22 23:17:54 +02:00
committed by Max P.
parent 4a97a46aed
commit ae9f25fe94

View File

@@ -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';
}
}