1 | import { NamedError } from '@salesforce/kit';
|
2 | import { JsonMap } from '@salesforce/ts-types';
|
3 | /**
|
4 | * A generalized sfdx error which also contains an action. The action is used in the
|
5 | * CLI to help guide users past the error.
|
6 | *
|
7 | * To throw an error in a synchronous function you must either pass the error message and actions
|
8 | * directly to the constructor, e.g.
|
9 | *
|
10 | * ```
|
11 | * // To load a message bundle (Note that __dirname should contain a messages folder)
|
12 | * Messages.importMessagesDirectory(__dirname);
|
13 | * const messages = Messages.load('myPackageName', 'myBundleName');
|
14 | *
|
15 | * // To throw a non-bundle based error:
|
16 | * throw new SfError(message.getMessage('myError'), 'MyErrorName');
|
17 | * ```
|
18 | */
|
19 | export declare class SfError extends NamedError {
|
20 | #private;
|
21 | /**
|
22 | * Action messages. Hints to the users regarding what can be done to fix related issues.
|
23 | */
|
24 | actions?: string[];
|
25 | /**
|
26 | * SfdxCommand can return this process exit code.
|
27 | */
|
28 | exitCode: number;
|
29 | /**
|
30 | * The related context for this error.
|
31 | */
|
32 | context?: string;
|
33 | data?: unknown;
|
34 | /**
|
35 | * Create an SfError.
|
36 | *
|
37 | * @param message The error message.
|
38 | * @param name The error name. Defaults to 'SfError'.
|
39 | * @param actions The action message(s).
|
40 | * @param exitCodeOrCause The exit code which will be used by SfdxCommand or he underlying error that caused this error to be raised.
|
41 | * @param cause The underlying error that caused this error to be raised.
|
42 | */
|
43 | constructor(message: string, name?: string, actions?: string[], exitCodeOrCause?: number | Error, cause?: Error);
|
44 | get code(): string | undefined | any;
|
45 | set code(code: string);
|
46 | /**
|
47 | * Convert an Error to an SfError.
|
48 | *
|
49 | * @param err The error to convert.
|
50 | */
|
51 | static wrap(err: Error | string): SfError;
|
52 | /**
|
53 | * Sets the context of the error. For convenience `this` object is returned.
|
54 | *
|
55 | * @param context The command name.
|
56 | */
|
57 | setContext(context: string): SfError;
|
58 | /**
|
59 | * An additional payload for the error. For convenience `this` object is returned.
|
60 | *
|
61 | * @param data The payload data.
|
62 | */
|
63 | setData(data: unknown): SfError;
|
64 | /**
|
65 | * Convert an {this error.
SfError} state to an object. Returns a plain object representing the state of |
66 | */
|
67 | toObject(): JsonMap;
|
68 | }
|
69 | /**
|
70 | * @deprecated use SfError instead
|
71 | */
|
72 | export declare class SfdxError extends SfError {
|
73 | }
|