ActivationError.ts
60 lines
| 1.5 KiB
| video/mp2t
|
TypeScriptLexer
|
|
r0 | export interface ActivationItem { | ||
| name: string; | ||||
| service: string; | ||||
| } | ||||
|
|
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 name of the failed service | ||||
| */ | ||||
|
|
r4 | readonly service: string; | ||
|
|
r0 | |||
|
|
r9 | /** | ||
| * The exception which occurred during activation of the service | ||||
| */ | ||||
|
|
r4 | readonly innerException: unknown; | ||
|
|
r0 | |||
|
|
r9 | /** | ||
| * Error message | ||||
| */ | ||||
|
|
r4 | readonly message: string; | ||
|
|
r0 | |||
|
|
r1 | constructor(service: string, activationStack: ActivationItem[], innerException: unknown) { | ||
|
|
r0 | this.message = "Failed to activate the service"; | ||
| this.activationStack = activationStack; | ||||
| this.service = service; | ||||
| this.innerException = innerException; | ||||
| } | ||||
| toString() { | ||||
| const parts = [this.message]; | ||||
| if (this.service) | ||||
|
|
r1 | parts.push(`when activating: ${String(this.service)}`); | ||
|
|
r0 | |||
| if (this.innerException) | ||||
|
|
r1 | parts.push(`caused by: ${String(this.innerException)}`); | ||
|
|
r0 | |||
| if (this.activationStack) { | ||||
| parts.push("at"); | ||||
|
|
r1 | parts.push.apply(null, | ||
| this.activationStack | ||||
| .map(({ name, service }) => ` ${name} ${service}`) | ||||
| ); | ||||
|
|
r0 | |||
| } | ||||
| return parts.join("\n"); | ||||
| } | ||||
| } | ||||
