/
ImperativeError.ts
123 lines (111 loc) · 3.03 KB
/
ImperativeError.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/
import { IImperativeError } from "./doc/IImperativeError";
import { IImperativeErrorParms } from "./doc/IImperativeErrorParms";
/**
*
* @export
* @class ImperativeError
* @extends {Error}
*/
export class ImperativeError extends Error {
/**
* The message generated/specified for the error - used for display/message/diagnostic purposes
* @private
* @type {string}
* @memberof ImperativeError
*/
private mMessage: string;
/**
* Construct the Imperative error object. Contains the defaults of the error and optionally captures diagnostics
* and other information.
* @param {IImperativeError} details - the error details and text (stack, messages, etc.)
* @param {IImperativeErrorParms} parms - control parameters to indicate logging of node-report and more
*/
constructor(public mDetails: IImperativeError, parms?: IImperativeErrorParms) {
super();
this.mMessage = mDetails.msg;
/**
* If parms are present, handle them, otherwise perform the default diagnostic collection
*/
if (parms) {
/**
* Append a tag if present
*/
if (parms.tag) {
this.mMessage = parms.tag + ": " + this.mMessage;
}
}
}
/**
* Return causeErrors
* @readonly
* @type {any[]}
* @memberof ImperativeError
*/
public get causeErrors(): any {
return this.mDetails.causeErrors;
}
/**
* Return additionalDetails
* @readonly
* @type {string}
* @memberof ImperativeError
*/
public get additionalDetails(): string {
return this.mDetails.additionalDetails;
}
/**
* Return IImperativeError object
* @readonly
* @type {IImperativeError}
* @memberof ImperativeError
*/
public get details(): IImperativeError {
return this.mDetails;
}
/**
* Return errorCode
* @readonly
* @type {string}
* @memberof ImperativeError
*/
public get errorCode(): string {
return this.mDetails.errorCode;
}
/**
* Return whether or not the error dump should be suppressed
* @readonly
* @type {string}
* @memberof ImperativeError
*/
public get suppressDump(): boolean {
return this.mDetails.suppressDump;
}
/**
* Return stack info
* @readonly
* @type {string}
* @memberof ImperativeError
*/
public get stack(): string {
return this.mDetails.stack;
}
/**
* Accessor for the error message.
* @readonly
* @return {string}: The error message
* @memberof ImperativeError
*/
public get message(): string {
return this.mMessage;
}
}