@futdevpro/fsm-dynamo 1.5.60 → 1.5.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_models/control-models/error.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/error.control-model.js +71 -30
- package/lib/_models/control-models/error.control-model.js.map +1 -1
- package/lib/_models/control-models/error.control-model.spec.js +330 -47
- package/lib/_models/control-models/error.control-model.spec.js.map +1 -1
- package/lib/_models/data-models/metadata.data-model.d.ts.map +1 -1
- package/lib/_models/data-models/metadata.data-model.js +1 -4
- package/lib/_models/data-models/metadata.data-model.js.map +1 -1
- package/lib/_utils/log.util.d.ts.map +1 -1
- package/lib/_utils/log.util.js +4 -5
- package/lib/_utils/log.util.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +5 -6
- package/package.json +1 -1
- package/src/_models/control-models/error.control-model.spec.ts +379 -51
- package/src/_models/control-models/error.control-model.ts +60 -15
- package/src/_models/data-models/metadata.data-model.ts +1 -4
- package/src/_utils/log.util.ts +4 -5
|
@@ -66,7 +66,6 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
66
66
|
/** set simple properties */
|
|
67
67
|
this.___handled = Boolean(set?.handled ?? (set?.error as Dynamo_Error)?.___handled);
|
|
68
68
|
this.___status = set?.status ?? (set?.error as Dynamo_Error)?.___status;
|
|
69
|
-
|
|
70
69
|
this.___issuer = set?.issuer ?? (set?.error as Dynamo_Error)?.___issuer ?? dynamo_error_default.issuer;
|
|
71
70
|
this.___issuerSystem = set?.issuerSystem ?? (set?.error as Dynamo_Error)?.___issuerSystem ?? dynamo_error_default.issuerSystem;
|
|
72
71
|
this.___issuerService = set?.issuerService ?? (set?.error as Dynamo_Error)?.___issuerService ?? dynamo_error_default.issuerService;
|
|
@@ -75,6 +74,10 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
75
74
|
if (!set.errorCode) {
|
|
76
75
|
set.errorCode = dynamo_error_default.errorCode;
|
|
77
76
|
}
|
|
77
|
+
/** set default error (self defined) */
|
|
78
|
+
if (!set?.error) {
|
|
79
|
+
set.error = new Error();
|
|
80
|
+
}
|
|
78
81
|
|
|
79
82
|
/** set errorCodes */
|
|
80
83
|
const previousErrorCodes: string[] = [];
|
|
@@ -85,16 +88,22 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
85
88
|
set.errorCode = dynamo_error_default.errorCode;
|
|
86
89
|
}
|
|
87
90
|
this._errorCodes = [ ...previousErrorCodes, set?.errorCode ].filter(Boolean);
|
|
88
|
-
|
|
91
|
+
|
|
92
|
+
/** bring up non NTS and non default first error */
|
|
93
|
+
const filteredErrorCodes: string[] = this._errorCodes.filter(
|
|
94
|
+
(code: string) => code && code !== dynamo_error_default.errorCode && !code.includes('NTS-')
|
|
95
|
+
);
|
|
96
|
+
this._errorCode = filteredErrorCodes[0] ?? this._errorCodes?.[0];
|
|
97
|
+
const highlightedErrorCodeIndex: number = this._errorCodes.findIndex(code => code === filteredErrorCodes?.[0]);
|
|
89
98
|
|
|
90
99
|
/** set message */
|
|
91
100
|
if (!set.message) {
|
|
92
101
|
/** simple - non-dynamo - error */
|
|
93
102
|
if (!(set?.error as Dynamo_Error)?.flag?.includes('DYNAMO') && (set?.error as Error)?.message) {
|
|
94
103
|
set.message = (set?.error as Error)?.message;
|
|
95
|
-
} else {
|
|
104
|
+
} else if ((set.error as Error).stack) {
|
|
96
105
|
/** error not defined */
|
|
97
|
-
const posFull =
|
|
106
|
+
const posFull = (set.error as Error).stack.split('\n')?.[2]?.split('\\');
|
|
98
107
|
set.message = dynamo_error_default.message + '; ' + posFull[posFull.length - 1];
|
|
99
108
|
}
|
|
100
109
|
}
|
|
@@ -106,7 +115,11 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
106
115
|
previousErrorCodes.push((set?.error as Error)?.message);
|
|
107
116
|
}
|
|
108
117
|
this._messages = [ ...previousMessages, set?.message, ].filter(Boolean);
|
|
109
|
-
|
|
118
|
+
if (-1 < highlightedErrorCodeIndex && this._messages[highlightedErrorCodeIndex]) {
|
|
119
|
+
this._message = this._messages[highlightedErrorCodeIndex];
|
|
120
|
+
} else {
|
|
121
|
+
this._message = this._messages?.[0];
|
|
122
|
+
}
|
|
110
123
|
|
|
111
124
|
/** set userMessages */
|
|
112
125
|
const previousUserMessages: string[] = [];
|
|
@@ -116,11 +129,17 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
116
129
|
if (!set.userMessage) {
|
|
117
130
|
set.userMessage = dynamo_error_default.userMessage;
|
|
118
131
|
}
|
|
119
|
-
if (set.addECToUserMsg && set.errorCode) {
|
|
132
|
+
if (set.addECToUserMsg && set.userMessage !== dynamo_error_default.userMessage && set.errorCode) {
|
|
120
133
|
set.userMessage += `\nErrorCode: ${set.errorCode}`
|
|
121
134
|
}
|
|
122
135
|
this.__userMessages = [ ...previousUserMessages, set?.userMessage ].filter(Boolean);
|
|
123
|
-
|
|
136
|
+
if (-1 < highlightedErrorCodeIndex && this.__userMessages[highlightedErrorCodeIndex]) {
|
|
137
|
+
this.__userMessage = this.__userMessages[highlightedErrorCodeIndex];
|
|
138
|
+
} else {
|
|
139
|
+
this.__userMessage = this.__userMessages.filter(
|
|
140
|
+
(msg: string) => msg && msg !== dynamo_error_default.userMessage
|
|
141
|
+
)?.[0];
|
|
142
|
+
}
|
|
124
143
|
|
|
125
144
|
/** set errors */
|
|
126
145
|
const previousErrors: (Error | Dynamo_Error)[] = [];
|
|
@@ -129,6 +148,17 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
129
148
|
}
|
|
130
149
|
this.errors = [ ...previousErrors, set?.error ].filter(Boolean);
|
|
131
150
|
this.error = this.errors?.[0];
|
|
151
|
+
this.errors.map((error: Error | Dynamo_Error) => {
|
|
152
|
+
if ((error as Dynamo_Error)?.flag?.includes('DYNAMO')) {
|
|
153
|
+
const subError = { ...error };
|
|
154
|
+
|
|
155
|
+
if ((subError as Dynamo_Error)?.errors) {
|
|
156
|
+
delete (subError as Dynamo_Error).errors;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return subError;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
132
162
|
|
|
133
163
|
if (set?.modestLog) {
|
|
134
164
|
console.error(this._message ?? this.__userMessage ?? this.error)
|
|
@@ -148,10 +178,13 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
148
178
|
}
|
|
149
179
|
|
|
150
180
|
getErrorSimplified(): Dynamo_Error {
|
|
151
|
-
const error = this;
|
|
181
|
+
const error = { ...this };
|
|
152
182
|
|
|
153
183
|
delete error.errors;
|
|
154
184
|
|
|
185
|
+
if ((error.error as Dynamo_Error)?.error) {
|
|
186
|
+
delete (error.error as Dynamo_Error).error;
|
|
187
|
+
}
|
|
155
188
|
if ((error.error as Dynamo_Error)?.errors) {
|
|
156
189
|
delete (error.error as Dynamo_Error).errors;
|
|
157
190
|
}
|
|
@@ -160,15 +193,27 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
160
193
|
}
|
|
161
194
|
|
|
162
195
|
getErrorsFlat(): Dynamo_Error {
|
|
163
|
-
const error = this;
|
|
196
|
+
const error = { ...this };
|
|
197
|
+
|
|
198
|
+
if ((error.error as Dynamo_Error)?.error) {
|
|
199
|
+
delete (error.error as Dynamo_Error).error;
|
|
200
|
+
}
|
|
201
|
+
if ((error.error as Dynamo_Error)?.errors) {
|
|
202
|
+
delete (error.error as Dynamo_Error).errors;
|
|
203
|
+
}
|
|
164
204
|
|
|
165
|
-
error.errors.
|
|
166
|
-
|
|
167
|
-
|
|
205
|
+
error.errors.map((err: Dynamo_Error) => {
|
|
206
|
+
const subError = { ...err };
|
|
207
|
+
|
|
208
|
+
if (subError.errors) {
|
|
209
|
+
delete subError.errors;
|
|
168
210
|
}
|
|
169
|
-
|
|
170
|
-
if ((
|
|
171
|
-
delete (
|
|
211
|
+
|
|
212
|
+
if ((subError.error as Dynamo_Error)?.errors) {
|
|
213
|
+
delete (subError.error as Dynamo_Error).errors;
|
|
214
|
+
}
|
|
215
|
+
if ((subError.error as Dynamo_Error)?.error) {
|
|
216
|
+
delete (subError.error as Dynamo_Error).error;
|
|
172
217
|
}
|
|
173
218
|
});
|
|
174
219
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Dynamo_Error } from '../control-models';
|
|
2
1
|
|
|
3
2
|
export type D_Metadata = Dynamo_Metadata;
|
|
4
3
|
export type D_MetaD = Dynamo_Metadata;
|
|
@@ -58,9 +57,7 @@ export class Dynamo_Metadata {
|
|
|
58
57
|
|
|
59
58
|
if (forceUpdate?.issuer) {
|
|
60
59
|
if (!this._id && forceUpdate.throwOnMissingId) {
|
|
61
|
-
throw new
|
|
62
|
-
message: `Dynamo_Metadata.constructor: missing _id`,
|
|
63
|
-
});
|
|
60
|
+
throw new Error(`Dynamo_Metadata.constructor: missing _id`);
|
|
64
61
|
}
|
|
65
62
|
this.__lastModified = new Date();
|
|
66
63
|
this.__lastModifiedBy = forceUpdate.issuer;
|
package/src/_utils/log.util.ts
CHANGED
|
@@ -8,16 +8,15 @@ export type D_L = Dynamo_Log;
|
|
|
8
8
|
|
|
9
9
|
export class Dynamo_Log {
|
|
10
10
|
static highlightedLog(message: string, ...optionalParams: any[]): void {
|
|
11
|
-
console.log('\n\n
|
|
11
|
+
console.log('\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! TEST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n');
|
|
12
12
|
console.log(message, ...optionalParams);
|
|
13
|
-
console.log('
|
|
13
|
+
console.log('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! TEST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n');
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
static testLog(message: string, ...optionalParams: any[]): void {
|
|
17
|
-
console.log('\n\n
|
|
18
|
-
console.log('TEST');
|
|
17
|
+
console.log('\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! TEST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n');
|
|
19
18
|
console.log(message, ...optionalParams);
|
|
20
|
-
console.log('
|
|
19
|
+
console.log('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! TEST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n');
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
static setStyle(styles: Dynamo_LogStyle[]): void {
|