UNPKG

2.6 kBTypeScriptView Raw
1/** A valid Errlop or Error instance. */
2export type ErrorValid = Errlop | Error;
3/** Properties {@link Errlop} supports. */
4export interface ErrorProperties {
5 /** The description of this error. */
6 message: string;
7 /** The code to identify this error. If a string code, it will be included in the stack. */
8 code: string | number;
9 /** The severity level of this error. */
10 level: string | number;
11 /** The parent that caused this error, if any. If not provided, inherited from `cause` property. */
12 parent: ErrorValid | null;
13 /** An array of the {@link parent} lineage. Most immediate to most distant. */
14 ancestors: Array<ErrorValid>;
15 /** A numeric code that can be used for the process exit status. If not provided, inherited from {@link ancestors} `exitCode`, `errno`, `code` numeric properties. */
16 exitCode: number | null;
17 /** The stack of this error alone, without any ancestry. */
18 orphanStack: string;
19 /** The stack of this error including its ancestry. */
20 stack: string;
21}
22/** An input that can become an Errlop or Error instance. */
23export type ErrorInput = Errlop | Error | Partial<ErrorProperties> | string | any;
24/** Errlop, an extended Error class that envelops a parent Error to provide ancestry stack inforation. */
25export default class Errlop extends Error implements ErrorProperties {
26 parent: ErrorValid | null;
27 ancestors: Array<ErrorValid>;
28 exitCode: number | null;
29 orphanStack: string;
30 stack: string;
31 message: string;
32 code: string | number;
33 level: string | number;
34 /** Duck typing so native classes can work with transpiled classes, as otherwise they would fail instanceof checks. */
35 klass: typeof Errlop;
36 /** Turn the input and parent into an Errlop instance. */
37 constructor(input: ErrorInput, parent?: ErrorInput);
38 /** The separator to use for the stack entries */
39 static stackSeparator: string;
40 /** Check whether or not the value is an Errlop instance */
41 static isErrlop(value: Errlop): true;
42 static isErrlop(value?: any): value is Errlop;
43 /** Check whether or not the value is an Errlop or Error instance. */
44 static isError(value: ErrorValid): true;
45 static isError(value?: any): value is ErrorValid;
46 /** Ensure that the value is an Errlop instance */
47 static ensure(value: ErrorInput): Errlop;
48 /**
49 * Syntactic sugar for Errlop class creation.
50 * Enables `Errlop.create(...)` to achieve `new Errlop(...)`
51 */
52 static create(input: ErrorInput, parent?: ErrorInput): Errlop;
53}
54//# sourceMappingURL=index.d.ts.map
\No newline at end of file