##// END OF EJS Templates
WIP lifetime services
WIP lifetime services

File last commit:

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