export interface ActivationItem { name: string; descriptor: string; } /** * Contains information about the error which occurred during service activation. * * Information about activation error includes original exception which has * occurred, the name of the service being activated and activation stack of * services. */ export class ActivationError { /** * Stack of services being activating */ readonly activationStack: ActivationItem[]; /** * The exception which occurred during activation of the service */ readonly innerException: unknown; /** * Error message */ readonly message: string; constructor(message: string, activationStack: ActivationItem[], innerException?: unknown) { this.message = message; this.activationStack = activationStack; this.innerException = innerException; } toString() { const parts = [this.message]; if (this.activationStack && this.activationStack.length) { const [{ name, descriptor }, ...before] = this.activationStack; parts.push(`when activating: ${name}, ${descriptor}`); if (before) { parts.push("at"); parts.push.apply( null, before.map(({ name: name, descriptor: service }) => ` ${name} ${service}`) ); } } if (this.innerException) parts.push(`caused by: ${String(this.innerException)}`); return parts.join("\n"); } }