yerror 7.0.0 → 9.0.0

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/src/index.test.ts CHANGED
@@ -1,137 +1,120 @@
1
- /* eslint max-nested-callbacks:[0], no-magic-numbers:[0] */
2
- import { describe, test } from '@jest/globals';
3
- import assert from 'assert';
1
+ import { describe, test, expect } from '@jest/globals';
4
2
  import { YError } from './index.js';
5
3
 
6
4
  describe('YError', () => {
7
5
  describe('.__constructor', () => {
8
6
  test('Should work', () => {
9
- const err = new YError('E_ERROR', 'arg1', 'arg2');
7
+ const err = new YError('E_ERROR', ['arg1', 'arg2']);
10
8
 
11
- assert(err instanceof Error);
12
- assert.equal(err.name, err.toString());
13
- assert.equal(err.code, 'E_ERROR');
14
- assert.deepEqual(err.params, ['arg1', 'arg2']);
15
- assert.equal(err.toString(), 'YError: E_ERROR (arg1, arg2)');
9
+ expect(err instanceof Error).toBeTruthy();
10
+ expect(err.name).toEqual(err.toString());
11
+ expect(err.code).toEqual('E_ERROR');
12
+ expect(err.debugValues).toEqual(['arg1', 'arg2']);
13
+ expect(err.toString()).toEqual('YError: E_ERROR (["arg1","arg2"])');
16
14
  });
17
15
  test('Should work without code', () => {
18
16
  const err = new YError();
19
17
 
20
- assert.equal(err.code, 'E_UNEXPECTED');
21
- assert.deepEqual(err.params, []);
22
- assert.equal(err.toString(), 'YError: E_UNEXPECTED ()');
23
- assert.equal(err.name, err.toString());
18
+ expect(err.code).toEqual('E_UNEXPECTED');
19
+ expect(err.debugValues).toEqual([]);
20
+ expect(err.toString()).toEqual('YError: E_UNEXPECTED ([])');
21
+ expect(err.name).toEqual(err.toString());
24
22
  });
25
23
  test('Should work without new', () => {
26
- const err = new YError('E_ERROR', 'arg1', 'arg2');
24
+ const err = new YError('E_ERROR', ['arg1', 'arg2']);
27
25
 
28
- assert.equal(err.code, 'E_ERROR');
29
- assert(err instanceof YError);
30
- assert.deepEqual(err.params, ['arg1', 'arg2']);
31
- assert.equal(err.toString(), 'YError: E_ERROR (arg1, arg2)');
32
- assert.equal(err.name, err.toString());
26
+ expect(err.code).toEqual('E_ERROR');
27
+ expect(err instanceof YError).toBeTruthy();
28
+ expect(err.debugValues).toEqual(['arg1', 'arg2']);
29
+ expect(err.toString()).toEqual('YError: E_ERROR (["arg1","arg2"])');
30
+ expect(err.name).toEqual(err.toString());
33
31
  });
34
32
  });
35
33
 
36
34
  describe('.wrap()', () => {
37
35
  test('Should work with standard errors and a message', () => {
38
- // eslint-disable-line
39
36
  const err = YError.wrap(new Error('This is an error!'));
40
37
 
41
- assert.equal(err.code, 'E_UNEXPECTED');
42
- assert.equal(err.wrappedErrors.length, 1);
43
- assert.deepEqual(err.params, ['This is an error!']);
38
+ expect(err.code).toEqual('E_UNEXPECTED');
39
+ expect(err.wrappedErrors.length).toEqual(1);
40
+ expect(err.debugValues).toEqual([]);
44
41
 
45
42
  if ('captureStackTrace' in Error) {
46
- assert(
43
+ expect(
47
44
  -1 !== (err.stack || '').indexOf('Error: This is an error!'),
48
- 'Stack contains original error.',
49
- );
50
- assert(
51
- -1 !==
52
- (err.stack || '').indexOf(
53
- 'YError: E_UNEXPECTED (This is an error!)',
54
- ),
55
- 'Stack contains cast error.',
56
- );
57
- assert.equal(err.name, err.toString());
45
+ ).toBeTruthy();
46
+ expect(
47
+ -1 !== (err.stack || '').indexOf('YError: E_UNEXPECTED ([])'),
48
+ ).toBeTruthy();
49
+ expect(err.name).toEqual(err.toString());
58
50
  }
59
51
  });
60
52
 
61
53
  test('Should work with standard errors and an error code', () => {
62
54
  const err = YError.wrap(new Error('E_ERROR'));
63
55
 
64
- assert.equal(err.code, 'E_ERROR');
65
- assert.equal(err.wrappedErrors.length, 1);
66
- assert.deepEqual(err.params, []);
56
+ expect(err.code).toEqual('E_ERROR');
57
+ expect(err.wrappedErrors.length).toEqual(1);
58
+ expect(err.debugValues).toEqual([]);
67
59
 
68
60
  if ('captureStackTrace' in Error) {
69
- assert(
70
- -1 !== (err.stack || '').indexOf('Error: E_ERROR'),
71
- 'Stack contains original error.',
72
- );
73
- assert(
74
- -1 !== (err.stack || '').indexOf('YError: E_ERROR ()'),
75
- 'Stack contains cast error.',
76
- );
61
+ expect(-1 !== (err.stack || '').indexOf('Error: E_ERROR')).toBeTruthy();
62
+ expect(
63
+ -1 !== (err.stack || '').indexOf('YError: E_ERROR ([])'),
64
+ ).toBeTruthy();
77
65
  }
78
- assert.equal(err.name, err.toString());
66
+ expect(err.name).toEqual(err.toString());
79
67
  });
80
68
 
81
69
  test('Should work with standard errors, an error code and params', () => {
82
- const err = YError.wrap(
83
- new Error('E_ERROR'),
84
- 'E_ERROR_2',
70
+ const err = YError.wrap(new Error('E_ERROR'), 'E_ERROR_2', [
85
71
  'arg1',
86
72
  'arg2',
87
- );
73
+ ]);
88
74
 
89
- assert.equal(err.code, 'E_ERROR_2');
90
- assert.equal(err.wrappedErrors.length, 1);
91
- assert.deepEqual(err.params, ['arg1', 'arg2']);
75
+ expect(err.code).toEqual('E_ERROR_2');
76
+ expect(err.wrappedErrors.length).toEqual(1);
77
+ expect(err.debugValues).toEqual(['arg1', 'arg2']);
92
78
 
93
79
  if ('captureStackTrace' in Error) {
94
- assert(
95
- -1 !== (err.stack || '').indexOf('Error: E_ERROR'),
96
- 'Stack contains first error.',
97
- );
98
- assert(
99
- -1 !== (err.stack || '').indexOf('YError: E_ERROR_2 (arg1, arg2)'),
100
- 'Stack contains second error.',
101
- );
80
+ expect(-1 !== (err.stack || '').indexOf('Error: E_ERROR')).toBeTruthy();
81
+ expect(
82
+ -1 !==
83
+ (err.stack || '').indexOf('YError: E_ERROR_2 (["arg1","arg2"])'),
84
+ ).toBeTruthy();
102
85
  }
103
- assert.equal(err.name, err.toString());
86
+ expect(err.name).toEqual(err.toString());
104
87
  });
105
88
 
106
89
  test('Should work with several wrapped errors', () => {
107
90
  const err = YError.wrap(
108
- YError.wrap(new Error('E_ERROR_1'), 'E_ERROR_2', 'arg2.1', 'arg2.2'),
91
+ YError.wrap(new Error('E_ERROR_1'), 'E_ERROR_2', ['arg2.1', 'arg2.2']),
109
92
  'E_ERROR_3',
110
- 'arg3.1',
111
- 'arg3.2',
93
+ ['arg3.1', 'arg3.2'],
112
94
  );
113
95
 
114
- assert.equal(err.code, 'E_ERROR_3');
115
- assert.equal(err.wrappedErrors.length, 2);
116
- assert.deepEqual(err.params, ['arg3.1', 'arg3.2']);
96
+ expect(err.code).toEqual('E_ERROR_3');
97
+ expect(err.wrappedErrors.length).toEqual(2);
98
+ expect(err.debugValues).toEqual(['arg3.1', 'arg3.2']);
117
99
 
118
100
  if ('captureStackTrace' in Error) {
119
- assert(
101
+ expect(
120
102
  -1 !== (err.stack || '').indexOf('Error: E_ERROR_1'),
121
- 'Stack contains first error.',
122
- );
123
- assert(
103
+ ).toBeTruthy();
104
+ expect(
124
105
  -1 !==
125
- (err.stack || '').indexOf('YError: E_ERROR_2 (arg2.1, arg2.2)'),
126
- 'Stack contains second error.',
127
- );
128
- assert(
106
+ (err.stack || '').indexOf(
107
+ 'YError: E_ERROR_2 (["arg2.1","arg2.2"])',
108
+ ),
109
+ ).toBeTruthy();
110
+ expect(
129
111
  -1 !==
130
- (err.stack || '').indexOf('YError: E_ERROR_3 (arg3.1, arg3.2)'),
131
- 'Stack contains second error.',
132
- );
112
+ (err.stack || '').indexOf(
113
+ 'YError: E_ERROR_3 (["arg3.1","arg3.2"])',
114
+ ),
115
+ ).toBeTruthy();
133
116
  }
134
- assert.equal(err.name, err.toString());
117
+ expect(err.name).toEqual(err.toString());
135
118
  });
136
119
  });
137
120
 
@@ -139,39 +122,33 @@ describe('YError', () => {
139
122
  test('Should work with standard errors and a message', () => {
140
123
  const err = YError.cast(new Error('This is an error!'));
141
124
 
142
- assert.equal(err.code, 'E_UNEXPECTED');
143
- assert.equal(err.wrappedErrors.length, 1);
144
- assert.deepEqual(err.params, ['This is an error!']);
125
+ expect(err.code).toEqual('E_UNEXPECTED');
126
+ expect(err.wrappedErrors.length).toEqual(1);
127
+ expect(err.debugValues).toEqual([]);
145
128
 
146
129
  if ('captureStackTrace' in Error) {
147
- assert(
130
+ expect(
148
131
  -1 !== (err.stack || '').indexOf('Error: This is an error!'),
149
- 'Stack contains original error.',
150
- );
151
- assert(
152
- -1 !==
153
- (err.stack || '').indexOf(
154
- 'YError: E_UNEXPECTED (This is an error!)',
155
- ),
156
- 'Stack contains cast error.',
157
- );
132
+ ).toBeTruthy();
133
+ expect(
134
+ -1 !== (err.stack || '').indexOf('YError: E_UNEXPECTED ([])'),
135
+ ).toBeTruthy();
158
136
  }
159
- assert.equal(err.name, err.toString());
137
+ expect(err.name).toEqual(err.toString());
160
138
  });
161
139
 
162
140
  test('Should let YError instances pass through', () => {
163
- const err = YError.cast(new YError('E_ERROR', 'arg1', 'arg2'));
141
+ const err = YError.cast(new YError('E_ERROR', ['arg1', 'arg2']));
164
142
 
165
- assert.equal(err.code, 'E_ERROR');
166
- assert.deepEqual(err.params, ['arg1', 'arg2']);
143
+ expect(err.code).toEqual('E_ERROR');
144
+ expect(err.debugValues).toEqual(['arg1', 'arg2']);
167
145
 
168
146
  if ('captureStackTrace' in Error) {
169
- assert(
170
- -1 !== (err.stack || '').indexOf('YError: E_ERROR (arg1, arg2)'),
171
- 'Stack contains cast error.',
172
- );
147
+ expect(
148
+ -1 !== (err.stack || '').indexOf('YError: E_ERROR (["arg1","arg2"])'),
149
+ ).toBeTruthy();
173
150
  }
174
- assert.equal(err.name, err.toString());
151
+ expect(err.name).toEqual(err.toString());
175
152
  });
176
153
  });
177
154
 
@@ -179,76 +156,68 @@ describe('YError', () => {
179
156
  test('Should work with standard errors and a message', () => {
180
157
  const err = YError.bump(new Error('This is an error!'));
181
158
 
182
- assert.equal(err.code, 'E_UNEXPECTED');
183
- assert.equal(err.wrappedErrors.length, 1);
184
- assert.deepEqual(err.params, ['This is an error!']);
159
+ expect(err.code).toEqual('E_UNEXPECTED');
160
+ expect(err.wrappedErrors.length).toEqual(1);
161
+ expect(err.debugValues).toEqual([]);
185
162
 
186
163
  if ('captureStackTrace' in Error) {
187
- assert(
164
+ expect(
188
165
  -1 !== (err.stack || '').indexOf('Error: This is an error!'),
189
- 'Stack contains original error.',
190
- );
191
- assert(
192
- -1 !==
193
- (err.stack || '').indexOf(
194
- 'YError: E_UNEXPECTED (This is an error!)',
195
- ),
196
- 'Stack contains bumped error.',
197
- );
166
+ ).toBeTruthy();
167
+ expect(
168
+ -1 !== (err.stack || '').indexOf('YError: E_UNEXPECTED ([])'),
169
+ ).toBeTruthy();
198
170
  }
199
- assert.equal(err.name, err.toString());
171
+ expect(err.name).toEqual(err.toString());
200
172
  });
201
173
 
202
174
  test('Should work with YError like errors', () => {
203
175
  const baseErr = new Error('E_A_NEW_ERROR');
204
176
 
205
177
  (baseErr as YError).code = 'E_A_NEW_ERROR';
206
- (baseErr as YError).params = ['baseParam1', 'baseParam2'];
178
+ (baseErr as YError).debugValues = ['baseParam1', 'baseParam2'];
207
179
 
208
180
  const err = YError.bump(baseErr);
209
181
 
210
- assert.equal(err.code, 'E_A_NEW_ERROR');
211
- assert.equal(err.wrappedErrors.length, 1);
212
- assert.deepEqual(err.params, ['baseParam1', 'baseParam2']);
182
+ expect(err.code).toEqual('E_A_NEW_ERROR');
183
+ expect(err.wrappedErrors.length).toEqual(1);
184
+ expect(err.debugValues).toEqual(['baseParam1', 'baseParam2']);
213
185
 
214
186
  if ('captureStackTrace' in Error) {
215
- assert(
187
+ expect(
216
188
  -1 !== (err.stack || '').indexOf('Error: E_A_NEW_ERROR'),
217
- 'Stack contains original error.',
218
- );
219
- assert(
189
+ ).toBeTruthy();
190
+ expect(
220
191
  -1 !==
221
192
  (err.stack || '').indexOf(
222
- 'YError: E_A_NEW_ERROR (baseParam1, baseParam2)',
193
+ 'YError: E_A_NEW_ERROR (["baseParam1","baseParam2"])',
223
194
  ),
224
- 'Stack contains bumped error.',
225
- );
195
+ ).toBeTruthy();
226
196
  }
227
- assert.equal(err.name, err.toString());
197
+ expect(err.name).toEqual(err.toString());
228
198
  });
229
199
 
230
200
  test('Should work with Y errors and a message', () => {
231
201
  const err = YError.bump(
232
- new YError('E_ERROR', 'arg1.1', 'arg1.2'),
202
+ new YError('E_ERROR', ['arg1.1', 'arg1.2']),
233
203
  'E_ERROR_2',
234
- 'arg2.1',
235
- 'arg2.2',
204
+ ['arg2.1', 'arg2.2'],
236
205
  );
237
206
 
238
- assert.equal(err.code, 'E_ERROR');
239
- assert.deepEqual(err.params, ['arg1.1', 'arg1.2']);
207
+ expect(err.code).toEqual('E_ERROR');
208
+ expect(err.debugValues).toEqual(['arg1.1', 'arg1.2']);
240
209
 
241
210
  if ('captureStackTrace' in Error) {
242
- assert(
243
- -1 !== (err.stack || '').indexOf('YError: E_ERROR (arg1.1, arg1.2)'),
244
- 'Stack contains original error.',
245
- );
246
- assert(
247
- -1 !== (err.stack || '').indexOf('YError: E_ERROR (arg1.1, arg1.2)'),
248
- 'Stack contains bumped error.',
249
- );
211
+ expect(
212
+ -1 !==
213
+ (err.stack || '').indexOf('YError: E_ERROR (["arg1.1","arg1.2"])'),
214
+ ).toBeTruthy();
215
+ expect(
216
+ -1 !==
217
+ (err.stack || '').indexOf('YError: E_ERROR (["arg1.1","arg1.2"])'),
218
+ ).toBeTruthy();
250
219
  }
251
- assert.equal(err.name, err.toString());
220
+ expect(err.name).toEqual(err.toString());
252
221
  });
253
222
  });
254
223
  });
package/src/index.ts CHANGED
@@ -1,47 +1,35 @@
1
- import os from 'os';
1
+ import { EOL } from 'node:os';
2
2
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
- type YErrorParams = any;
3
+ export type YErrorDebugValue = unknown;
5
4
 
6
5
  /**
7
- * A YError class able to contain some params and
6
+ * A YError class able to contain some debugValues and
8
7
  * print better stack traces
9
8
  * @extends Error
10
9
  */
11
- class YError extends Error {
10
+ class YError<T = YErrorDebugValue> extends Error {
12
11
  code: string;
13
- params: YErrorParams[];
14
- wrappedErrors: (Error | YError)[];
12
+ debugValues: T[] = [];
13
+ wrappedErrors: (Error | YError)[] = [];
15
14
  /**
16
15
  * Creates a new YError with an error code
17
- * and some params as debug values.
16
+ * and some debugValues as debug values.
18
17
  * @param {string} [errorCode = 'E_UNEXPECTED']
19
18
  * The error code corresponding to the actual error
20
- * @param {...YErrorParams} [params]
19
+ * @param {any} [debugValues]
21
20
  * Some additional debugging values
22
21
  */
23
- constructor(errorCode: string, ...params: YErrorParams[]);
24
22
  constructor(
25
- wrappedErrors?: Error[],
26
23
  errorCode?: string,
27
- ...params: YErrorParams[]
28
- );
29
- constructor(wrappedErrors, errorCode, ...params) {
30
- // Detecting if wrappedErrors are passed
31
- if (!(wrappedErrors instanceof Array)) {
32
- params = ('undefined' === typeof errorCode ? [] : [errorCode]).concat(
33
- params,
34
- );
35
- errorCode = wrappedErrors;
36
- wrappedErrors = [];
37
- }
38
-
24
+ debugValues: T[] = [],
25
+ wrappedErrors: (Error | YError)[] = [],
26
+ ) {
39
27
  // Call the parent constructor
40
28
  super(errorCode);
41
29
 
42
30
  // Filling error
43
31
  this.code = errorCode || 'E_UNEXPECTED';
44
- this.params = params;
32
+ this.debugValues = debugValues;
45
33
  this.wrappedErrors = wrappedErrors;
46
34
  this.name = this.toString();
47
35
 
@@ -52,22 +40,22 @@ class YError extends Error {
52
40
 
53
41
  /**
54
42
  * Wraps any error and output a YError with an error
55
- * code and some params as debug values.
43
+ * code and some debugValues as debug values.
56
44
  * @param {Error} err
57
45
  * The error to wrap
58
46
  * @param {string} [errorCode = 'E_UNEXPECTED']
59
47
  * The error code corresponding to the actual error
60
- * @param {...YErrorParams} [params]
48
+ * @param {any} [debugValues]
61
49
  * Some additional debugging values
62
50
  * @return {YError}
63
51
  * The wrapped error
64
52
  */
65
- static wrap<E extends Error | YError>(
66
- err: E,
53
+ static wrap<T = YErrorDebugValue>(
54
+ err: Error | YError,
67
55
  errorCode?: string,
68
- ...params: YErrorParams[]
56
+ debugValues: T[] = [],
69
57
  ): YError {
70
- const wrappedErrorIsACode = _looksLikeAYErrorCode(err.message);
58
+ const wrappedErrorIsACode = looksLikeAYErrorCode(err.message);
71
59
  const wrappedErrors = (
72
60
  'wrappedErrors' in err ? err.wrappedErrors : []
73
61
  ).concat(err);
@@ -79,33 +67,31 @@ class YError extends Error {
79
67
  errorCode = 'E_UNEXPECTED';
80
68
  }
81
69
  }
82
- if (err.message && !wrappedErrorIsACode) {
83
- params.push(err.message);
84
- }
85
- return new YError(wrappedErrors, errorCode, ...params);
70
+
71
+ return new YError(errorCode, debugValues, wrappedErrors);
86
72
  }
87
73
 
88
74
  /**
89
75
  * Return a YError as is or wraps any other error and output
90
- * a YError with a code and some params as debug values.
76
+ * a YError with a code and some debugValues as debug values.
91
77
  * @param {Error} err
92
78
  * The error to cast
93
79
  * @param {string} [errorCode = 'E_UNEXPECTED']
94
80
  * The error code corresponding to the actual error
95
- * @param {...YErrorParams} [params]
81
+ * @param {any} [debugValues]
96
82
  * Some additional debugging values
97
83
  * @return {YError}
98
84
  * The wrapped error
99
85
  */
100
- static cast<E extends Error | YError>(
101
- err: E,
86
+ static cast<T = YErrorDebugValue>(
87
+ err: Error | YError,
102
88
  errorCode?: string,
103
- ...params: YErrorParams[]
89
+ debugValues: T[] = [],
104
90
  ): YError {
105
- if (_looksLikeAYError(err)) {
106
- return err as unknown as YError;
91
+ if (looksLikeAYError(err)) {
92
+ return err;
107
93
  }
108
- return YError.wrap(err, errorCode, ...params);
94
+ return YError.wrap(err, errorCode, debugValues);
109
95
  }
110
96
 
111
97
  /**
@@ -116,40 +102,41 @@ class YError extends Error {
116
102
  * The error to bump
117
103
  * @param {string} [errorCode = 'E_UNEXPECTED']
118
104
  * The error code corresponding to the actual error
119
- * @param {...YErrorParams} [params]
105
+ * @param {any} [debugValues]
120
106
  * Some additional debugging values
121
107
  * @return {YError}
122
108
  * The wrapped error
123
109
  */
124
- static bump<E extends Error | YError>(
125
- err: E,
110
+ static bump<T = YErrorDebugValue>(
111
+ err: Error | YError,
126
112
  errorCode?: string,
127
- ...params: YErrorParams[]
113
+ debugValues: T[] = [],
128
114
  ): YError {
129
- if (_looksLikeAYError(err)) {
130
- return YError.wrap(err, (err as YError).code, ...(err as YError).params);
115
+ if (looksLikeAYError(err)) {
116
+ return YError.wrap(err, err.code, err.debugValues);
131
117
  }
132
- return YError.wrap(err, errorCode, ...params);
118
+ return YError.wrap(err, errorCode, debugValues);
133
119
  }
134
120
 
135
121
  toString(): string {
136
- return (
137
- (this.wrappedErrors.length
138
- ? // eslint-disable-next-line
139
- this.wrappedErrors[this.wrappedErrors.length - 1].stack + os.EOL
140
- : '') +
141
- this.constructor.name +
142
- ': ' +
143
- this.code +
144
- ' (' +
145
- this.params.join(', ') +
146
- ')'
147
- );
122
+ let debugValuesAsString: string;
123
+
124
+ try {
125
+ debugValuesAsString = JSON.stringify(this.debugValues);
126
+ } catch {
127
+ debugValuesAsString = '<circular>';
128
+ }
129
+
130
+ return `${
131
+ this.wrappedErrors.length
132
+ ? this.wrappedErrors[this.wrappedErrors.length - 1].stack + EOL
133
+ : ''
134
+ }${this.constructor.name}: ${this.code} (${debugValuesAsString})`;
148
135
  }
149
136
  }
150
137
 
151
138
  /**
152
- * Allow to print a stack from anything (especially catched
139
+ * Allow to print a stack from anything (especially caught
153
140
  * errors that may or may not contain errors 🤷).
154
141
  * @param {Error} err
155
142
  * The error to print
@@ -167,8 +154,8 @@ export function printStackTrace(err: Error | YError): string {
167
154
  }
168
155
 
169
156
  // In order to keep compatibility through major versions
170
- // we have to make kind of an cross major version instanceof
171
- function _looksLikeAYError(err: Error | YError): boolean {
157
+ // we have to make kind of a cross major version instanceof
158
+ export function looksLikeAYError(err: Error | YError): err is YError {
172
159
  return (
173
160
  !!(err instanceof YError) ||
174
161
  !!(
@@ -177,15 +164,15 @@ function _looksLikeAYError(err: Error | YError): boolean {
177
164
  err.constructor.name.endsWith('Error') &&
178
165
  'code' in err &&
179
166
  'string' === typeof err.code &&
180
- _looksLikeAYErrorCode(err.code) &&
181
- 'params' in err &&
182
- err.params &&
183
- err.params instanceof Array
167
+ looksLikeAYErrorCode(err.code) &&
168
+ 'debugValues' in err &&
169
+ err.debugValues &&
170
+ err.debugValues instanceof Array
184
171
  )
185
172
  );
186
173
  }
187
174
 
188
- function _looksLikeAYErrorCode(str: string): boolean {
175
+ export function looksLikeAYErrorCode(str: string): boolean {
189
176
  return /^([A-Z0-9_]+)$/.test(str);
190
177
  }
191
178