container.ts
Version:
Modular application framework
44 lines (43 loc) • 1.48 kB
TypeScript
export interface IErrorChain {
name: string;
value?: any;
}
export interface IErrorChainItem extends IErrorChain {
stack: string;
message?: string;
errno?: number;
code?: string;
path?: string;
syscall?: string;
}
export interface IErrorChainSerialised {
ErrorChain: IErrorChainItem[];
}
export declare class ErrorChain {
/** Error names. */
static readonly ERROR: {
SERIALISE: string;
DESERIALISE: string;
};
/** Returns true if error instance of ErrorChain. */
static isErrorChain(error: any): error is ErrorChain;
/** Returns true if error instance of Error or ErrorChain */
static isError(error: any): error is Error | ErrorChain;
/** Construct error message from data and optional cause. */
static messageConstructor(data: IErrorChain, cause?: ErrorChain | Error): string;
/** Return serialisable object of generic error data. */
static serialiseError(error: any): IErrorChainItem;
/** Return deserialised ErrorChain instance of serialised data. */
static deserialise(serialised: IErrorChainSerialised): ErrorChain | null;
name: string;
stack?: string;
message?: string;
value?: any;
cause?: ErrorChain | Error;
constructor(data: IErrorChain, cause?: ErrorChain | Error);
toString(): string;
/** Join chained error names. */
joinNames(separator?: string): string;
serialise(): IErrorChainSerialised;
}
export default ErrorChain;