UNPKG

@apiratorjs/di-container

Version:

A lightweight dependency injection container for JavaScript and TypeScript with powerful features: modular organization with DiModule.create, lazy initialization, automatic circular dependency detection, and multiple service lifecycles (singleton with bot

34 lines 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RequestScopeResolutionError = exports.UnregisteredDependencyError = exports.CircularDependencyError = void 0; class BaseApiratorjsError extends Error { constructor(message, cause) { super(message); this.cause = cause; this.name = this.constructor.name; this.cause = cause; Error.captureStackTrace(this, this.constructor); } } class CircularDependencyError extends BaseApiratorjsError { constructor(token, chain) { super(`Circular dependency detected for token ${token.toString()}`, chain.join(" -> ")); this.chain = chain; } } exports.CircularDependencyError = CircularDependencyError; class UnregisteredDependencyError extends BaseApiratorjsError { constructor(token, cause) { super(`Service for token ${token.toString()} is not registered`, cause); this.cause = cause; } } exports.UnregisteredDependencyError = UnregisteredDependencyError; class RequestScopeResolutionError extends BaseApiratorjsError { constructor(token, cause) { super(`Cannot resolve request-scoped service for token '${token.toString()}' outside of a request scope. It is likely that a singleton or transient service is trying to inject a request-scoped dependency.`, cause); this.cause = cause; } } exports.RequestScopeResolutionError = RequestScopeResolutionError; //# sourceMappingURL=errors.js.map