@netflix/nerror 1.1.2 → 2.0.0-rc.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 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(): Error | undefined;
14
+ cause: Error | undefined;
15
15
  constructor(
16
16
  options: VError.Options | Error,
17
17
  message: string,
package/lib/verror.js CHANGED
@@ -134,7 +134,10 @@ function parseConstructorArguments(args) {
134
134
 
135
135
  if (sprintf_args.length === 0) {
136
136
  shortmessage = '';
137
- } else if (options.skipPrintf) {
137
+ } else if (
138
+ options.skipPrintf ||
139
+ (sprintf_args.length === 1 && typeof sprintf_args[0] === 'string')
140
+ ) {
138
141
  assert.equal(
139
142
  sprintf_args.length,
140
143
  1,
@@ -248,7 +251,12 @@ function VError(...args) {
248
251
  const cause = parsed.options.cause;
249
252
  if (cause) {
250
253
  VError._assertError(cause, '"cause" must be an Error');
251
- this.jse_cause = cause;
254
+ Object.defineProperty(this, 'cause', {
255
+ enumerable: false,
256
+ configurable: true,
257
+ writable: true,
258
+ value: cause
259
+ });
252
260
 
253
261
  if (!parsed.options.skipCauseMessage) {
254
262
  message += ': ' + cause.message;
@@ -324,19 +332,6 @@ VError.prototype.toString = function ve_toString() {
324
332
  return str;
325
333
  };
326
334
 
327
- /**
328
- * This method is provided for compatibility. New callers should use
329
- * VError.cause() instead. That method also uses the saner `null` return value
330
- * when there is no cause.
331
- * @public
332
- * @memberof VError.prototype
333
- * @return {undefined|Error} Error cause if any
334
- */
335
- VError.prototype.cause = function ve_cause() {
336
- const cause = VError.cause(this);
337
- return cause === null ? undefined : cause;
338
- };
339
-
340
335
  /*
341
336
  * Static methods
342
337
  *
@@ -416,7 +411,7 @@ VError.assignInfo = function assignInfo(err, obj) {
416
411
  */
417
412
  VError.cause = function cause(err) {
418
413
  VError._assertError(err);
419
- return _.isError(err.jse_cause) ? err.jse_cause : null;
414
+ return _.isError(err.cause) ? err.cause : null;
420
415
  };
421
416
 
422
417
  /**
@@ -786,25 +781,9 @@ WError.prototype.toString = function we_toString() {
786
781
  if (this.message) {
787
782
  str += ': ' + this.message;
788
783
  }
789
- if (this.jse_cause && this.jse_cause.message) {
790
- str += '; caused by ' + this.jse_cause.toString();
784
+ if (this.cause && this.cause.message) {
785
+ str += '; caused by ' + this.cause.toString();
791
786
  }
792
787
 
793
788
  return str;
794
789
  };
795
-
796
- /**
797
- * For purely historical reasons, WError's cause() function allows you to set
798
- * the cause.
799
- * @public
800
- * @memberof WError.prototype
801
- * @param {Error} c - cause
802
- * @return {undefined|Error} Error cause
803
- */
804
- WError.prototype.cause = function we_cause(c) {
805
- if (_.isError(c)) {
806
- this.jse_cause = c;
807
- }
808
-
809
- return this.jse_cause;
810
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netflix/nerror",
3
- "version": "1.1.2",
3
+ "version": "2.0.0-rc.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": ">=20"
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.7.3",
37
+ "tsd": "^0.33.0",
35
38
  "unleash": "^2.0.1"
36
39
  },
37
40
  "dependencies": {
package/CHANGELOG.md DELETED
@@ -1,32 +0,0 @@
1
- <a name="1.1.2"></a>
2
- ### 1.1.2 (2019-07-26)
3
-
4
-
5
- <a name="1.1.1"></a>
6
- ### 1.1.1 (2019-07-09)
7
-
8
-
9
- <a name="1.1.0"></a>
10
- ## 1.1.0 (2019-05-06)
11
-
12
-
13
- #### Features
14
-
15
- * **errorForEach:** make it MultiError support more general (#2) ([96cc8769](https://github.com/Netflix/nerror/commit/96cc8769))
16
-
17
-
18
- <a name="1.0.0"></a>
19
- ## 1.0.0 (2019-05-02)
20
-
21
-
22
- #### Features
23
-
24
- * **nerror:** initial commit ([c959d4fc](https://github.com/Netflix/nerror/commit/c959d4fc))
25
-
26
-
27
- #### Breaking Changes
28
-
29
- * initial release
30
-
31
- ([6ae8bd30](https://github.com/Netflix/nerror/commit/6ae8bd30))
32
-