di-tory
Version:
Compose applications with dependency injection
21 lines (20 loc) • 1.01 kB
JavaScript
export var DependencyResolutionErrorCode;
(function (DependencyResolutionErrorCode) {
DependencyResolutionErrorCode["PrivateMemberAccessFailure"] = "PrivateMemberAccessFailure";
DependencyResolutionErrorCode["CircularDependencyFailure"] = "CircularDependencyFailure";
DependencyResolutionErrorCode["ResolverIsNotDefined"] = "ResolverIsNotDefined";
DependencyResolutionErrorCode["InstantiationFailure"] = "InstantiationFailure";
})(DependencyResolutionErrorCode || (DependencyResolutionErrorCode = {}));
export class DependencyResolutionError extends Error {
constructor(code, resolutionStack, item, cause) {
const stackMessage = resolutionStack.length > 0
? ` with stack ${resolutionStack.map((parent) => `<${parent}>`).join(' <- ')}`
: '';
super(`${code} in attempting to resolve <${item}>${stackMessage}`, {
cause,
});
this.code = code;
this.resolutionStack = resolutionStack;
this.item = item;
}
}