ActivationError.ts
57 lines
| 1.5 KiB
| video/mp2t
|
TypeScriptLexer
|
|
r0 | export interface ActivationItem { | ||
| name: string; | ||||
|
|
r15 | descriptor: string; | ||
|
|
r0 | } | ||
|
|
r9 | /** | ||
| * 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. | ||||
| */ | ||||
|
|
r0 | export class ActivationError { | ||
|
|
r9 | /** | ||
| * Stack of services being activating | ||||
| */ | ||||
|
|
r4 | readonly activationStack: ActivationItem[]; | ||
|
|
r0 | |||
|
|
r9 | /** | ||
| * The exception which occurred during activation of the service | ||||
| */ | ||||
|
|
r4 | readonly innerException: unknown; | ||
|
|
r0 | |||
|
|
r9 | /** | ||
| * Error message | ||||
| */ | ||||
|
|
r4 | readonly message: string; | ||
|
|
r0 | |||
|
|
r15 | constructor(message: string, activationStack: ActivationItem[], innerException?: unknown) { | ||
| this.message = message; | ||||
|
|
r0 | this.activationStack = activationStack; | ||
| this.innerException = innerException; | ||||
| } | ||||
| toString() { | ||||
| const parts = [this.message]; | ||||
|
|
r15 | |||
| 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}`) | ||||
| ); | ||||
| } | ||||
| } | ||||
|
|
r0 | |||
| if (this.innerException) | ||||
|
|
r1 | parts.push(`caused by: ${String(this.innerException)}`); | ||
|
|
r0 | |||
| return parts.join("\n"); | ||||
| } | ||||
| } | ||||
