1 | import { AnyJson } from '@salesforce/ts-types';
|
2 | export type SfErrorOptions<T extends ErrorDataProperties = ErrorDataProperties> = {
|
3 | message: string;
|
4 | exitCode?: number;
|
5 | name?: string;
|
6 | data?: T;
|
7 |
|
8 | cause?: unknown;
|
9 | context?: string;
|
10 | actions?: string[];
|
11 | };
|
12 | type ErrorDataProperties = AnyJson;
|
13 | type SfErrorToObjectResult = {
|
14 | name: string;
|
15 | message: string;
|
16 | exitCode: number;
|
17 | actions?: string[];
|
18 | context?: string;
|
19 | data?: ErrorDataProperties;
|
20 | };
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | export declare class SfError<T extends ErrorDataProperties = ErrorDataProperties> extends Error {
|
38 | #private;
|
39 | readonly name: string;
|
40 | |
41 |
|
42 |
|
43 | actions?: string[];
|
44 | |
45 |
|
46 |
|
47 | exitCode: number;
|
48 | |
49 |
|
50 |
|
51 | context?: string;
|
52 | data?: T;
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | constructor(message: string, name?: string, actions?: string[], exitCodeOrCause?: number | Error, cause?: unknown);
|
63 | get code(): string;
|
64 | set code(code: string);
|
65 | /** like the constructor, but takes an typed object and let you also set context and data properties */
|
66 | static create<T extends ErrorDataProperties = ErrorDataProperties>(inputs: SfErrorOptions<T>): SfError<T>;
|
67 | /**
|
68 | * Convert an Error to an SfError.
|
69 | *
|
70 | * @param err The error to convert.
|
71 | */
|
72 | static wrap<T extends ErrorDataProperties = ErrorDataProperties>(err: unknown): SfError<T>;
|
73 | /**
|
74 | * Sets the context of the error. For convenience `this` object is returned.
|
75 | *
|
76 | * @param context The command name.
|
77 | */
|
78 | setContext(context: string): SfError;
|
79 | /**
|
80 | * An additional payload for the error. For convenience `this` object is returned.
|
81 | *
|
82 | * @param data The payload data.
|
83 | */
|
84 | setData(data: T): SfError;
|
85 | /**
|
86 | * Convert an {@link SfError} state to an object. Returns a plain object representing the state of this error.
|
87 | */
|
88 | toObject(): SfErrorToObjectResult;
|
89 | }
|
90 | export {};
|