@netflix/nerror 1.1.3 → 2.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/lib/index.d.ts +1 -1
- package/lib/verror.js +9 -33
- package/package.json +5 -2
- package/CHANGELOG.md +0 -41
package/lib/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export class VError extends Error {
|
|
|
11
11
|
): null | T | VError.MultiError;
|
|
12
12
|
static errorForEach(err: Error, func: (err: Error) => void): void;
|
|
13
13
|
|
|
14
|
-
cause
|
|
14
|
+
cause: Error | undefined;
|
|
15
15
|
constructor(
|
|
16
16
|
options: VError.Options | Error,
|
|
17
17
|
message: string,
|
package/lib/verror.js
CHANGED
|
@@ -251,7 +251,12 @@ function VError(...args) {
|
|
|
251
251
|
const cause = parsed.options.cause;
|
|
252
252
|
if (cause) {
|
|
253
253
|
VError._assertError(cause, '"cause" must be an Error');
|
|
254
|
-
this
|
|
254
|
+
Object.defineProperty(this, 'cause', {
|
|
255
|
+
enumerable: false,
|
|
256
|
+
configurable: true,
|
|
257
|
+
writable: true,
|
|
258
|
+
value: cause
|
|
259
|
+
});
|
|
255
260
|
|
|
256
261
|
if (!parsed.options.skipCauseMessage) {
|
|
257
262
|
message += ': ' + cause.message;
|
|
@@ -327,19 +332,6 @@ VError.prototype.toString = function ve_toString() {
|
|
|
327
332
|
return str;
|
|
328
333
|
};
|
|
329
334
|
|
|
330
|
-
/**
|
|
331
|
-
* This method is provided for compatibility. New callers should use
|
|
332
|
-
* VError.cause() instead. That method also uses the saner `null` return value
|
|
333
|
-
* when there is no cause.
|
|
334
|
-
* @public
|
|
335
|
-
* @memberof VError.prototype
|
|
336
|
-
* @return {undefined|Error} Error cause if any
|
|
337
|
-
*/
|
|
338
|
-
VError.prototype.cause = function ve_cause() {
|
|
339
|
-
const cause = VError.cause(this);
|
|
340
|
-
return cause === null ? undefined : cause;
|
|
341
|
-
};
|
|
342
|
-
|
|
343
335
|
/*
|
|
344
336
|
* Static methods
|
|
345
337
|
*
|
|
@@ -419,7 +411,7 @@ VError.assignInfo = function assignInfo(err, obj) {
|
|
|
419
411
|
*/
|
|
420
412
|
VError.cause = function cause(err) {
|
|
421
413
|
VError._assertError(err);
|
|
422
|
-
return _.isError(err.
|
|
414
|
+
return _.isError(err.cause) ? err.cause : null;
|
|
423
415
|
};
|
|
424
416
|
|
|
425
417
|
/**
|
|
@@ -789,25 +781,9 @@ WError.prototype.toString = function we_toString() {
|
|
|
789
781
|
if (this.message) {
|
|
790
782
|
str += ': ' + this.message;
|
|
791
783
|
}
|
|
792
|
-
if (this.
|
|
793
|
-
str += '; caused by ' + this.
|
|
784
|
+
if (this.cause && this.cause.message) {
|
|
785
|
+
str += '; caused by ' + this.cause.toString();
|
|
794
786
|
}
|
|
795
787
|
|
|
796
788
|
return str;
|
|
797
789
|
};
|
|
798
|
-
|
|
799
|
-
/**
|
|
800
|
-
* For purely historical reasons, WError's cause() function allows you to set
|
|
801
|
-
* the cause.
|
|
802
|
-
* @public
|
|
803
|
-
* @memberof WError.prototype
|
|
804
|
-
* @param {Error} c - cause
|
|
805
|
-
* @return {undefined|Error} Error cause
|
|
806
|
-
*/
|
|
807
|
-
WError.prototype.cause = function we_cause(c) {
|
|
808
|
-
if (_.isError(c)) {
|
|
809
|
-
this.jse_cause = c;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
return this.jse_cause;
|
|
813
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netflix/nerror",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"description": "Rich errors",
|
|
6
6
|
"homepage": "https://github.com/Netflix/nerror",
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"url": "https://github.com/Netflix/nerror"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=24"
|
|
14
|
+
},
|
|
12
15
|
"files": [
|
|
13
16
|
"lib",
|
|
14
17
|
"lib/index.d.ts"
|
|
@@ -31,7 +34,7 @@
|
|
|
31
34
|
"mocha": "^5.2.0",
|
|
32
35
|
"nyc": "^12.0.2",
|
|
33
36
|
"prettier": "^1.13.5",
|
|
34
|
-
"tsd": "^0.
|
|
37
|
+
"tsd": "^0.33.0",
|
|
35
38
|
"unleash": "^2.0.1"
|
|
36
39
|
},
|
|
37
40
|
"dependencies": {
|
package/CHANGELOG.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<a name="1.1.3"></a>
|
|
2
|
-
### 1.1.3 (2019-11-27)
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
#### Bug Fixes
|
|
6
|
-
|
|
7
|
-
* **nerror:** don't call extsprintf if single string passed to VError constructor (#11) ([89b2088b](https://github.com/Netflix/nerror/commit/89b2088b))
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<a name="1.1.2"></a>
|
|
11
|
-
### 1.1.2 (2019-07-26)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<a name="1.1.1"></a>
|
|
15
|
-
### 1.1.1 (2019-07-09)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<a name="1.1.0"></a>
|
|
19
|
-
## 1.1.0 (2019-05-06)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
#### Features
|
|
23
|
-
|
|
24
|
-
* **errorForEach:** make it MultiError support more general (#2) ([96cc8769](https://github.com/Netflix/nerror/commit/96cc8769))
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<a name="1.0.0"></a>
|
|
28
|
-
## 1.0.0 (2019-05-02)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
#### Features
|
|
32
|
-
|
|
33
|
-
* **nerror:** initial commit ([c959d4fc](https://github.com/Netflix/nerror/commit/c959d4fc))
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
#### Breaking Changes
|
|
37
|
-
|
|
38
|
-
* initial release
|
|
39
|
-
|
|
40
|
-
([6ae8bd30](https://github.com/Netflix/nerror/commit/6ae8bd30))
|
|
41
|
-
|