@util.js/errors 0.41.5 → 0.41.6
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/package.json +1 -1
- package/dist/AsyncError.js +0 -49
- package/dist/Errors.js +0 -165
- package/dist/FalsyError.js +0 -30
- package/dist/MissingError.js +0 -30
- package/dist/RethrownError.js +0 -44
package/package.json
CHANGED
package/dist/AsyncError.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* See {@link Errors#AsyncError}.
|
|
5
|
-
*/
|
|
6
|
-
var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
|
|
7
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
8
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
9
|
-
var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
|
|
10
|
-
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
13
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
14
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
15
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
16
|
-
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
|
|
17
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
18
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
19
|
-
module.exports = /*#__PURE__*/function (_Error) {
|
|
20
|
-
function AsyncError(callerError, asyncError, message) {
|
|
21
|
-
var _context, _context2, _context3, _context4, _context5;
|
|
22
|
-
var _this;
|
|
23
|
-
(0, _classCallCheck2["default"])(this, AsyncError);
|
|
24
|
-
_this = _callSuper(this, AsyncError, [message != null ? message : getErrorProperty(asyncError, "message")]);
|
|
25
|
-
if (!callerError) throw new TypeError((0, _concat["default"])(_context = "".concat(_this.constructor.name, "'s constructor expects a defined callerError, but it was ")).call(_context, callerError, "."));
|
|
26
|
-
if (!asyncError) throw new TypeError((0, _concat["default"])(_context2 = "".concat(_this.constructor.name, "'s constructor expects a defined asyncError, but it was ")).call(_context2, asyncError, "."));
|
|
27
|
-
_this.name = _this.constructor.name;
|
|
28
|
-
_this.original = asyncError;
|
|
29
|
-
_this.newStack = _this.stack;
|
|
30
|
-
var callerStack = " at " + (0, _splice["default"])(_context3 = callerError.stack.split(" at ")).call(_context3, 2).join(" at ");
|
|
31
|
-
// If asyncError.stack is falsy, then let us just try asyncError;
|
|
32
|
-
// asyncError may be a string.
|
|
33
|
-
var asyncErrorStack = getErrorProperty(asyncError, "stack");
|
|
34
|
-
_this.stack = (0, _concat["default"])(_context4 = (0, _concat["default"])(_context5 = "".concat(_this.stack, "\n")).call(_context5, callerStack, "\n")).call(_context4, asyncErrorStack);
|
|
35
|
-
return _this;
|
|
36
|
-
}
|
|
37
|
-
(0, _inherits2["default"])(AsyncError, _Error);
|
|
38
|
-
return (0, _createClass2["default"])(AsyncError);
|
|
39
|
-
}(/*#__PURE__*/(0, _wrapNativeSuper2["default"])(Error));
|
|
40
|
-
function getErrorProperty(error, property) {
|
|
41
|
-
if (error[property]) return error[property];
|
|
42
|
-
try {
|
|
43
|
-
return (0, _stringify["default"])(error);
|
|
44
|
-
} catch (e) {
|
|
45
|
-
// JSON.stringify might throw the following, "TypeError: Converting circular
|
|
46
|
-
// structure to JSON."
|
|
47
|
-
return error;
|
|
48
|
-
}
|
|
49
|
-
}
|
package/dist/Errors.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* JavaScript utility methods for [errors]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
* @class Errors
|
|
8
|
-
*/
|
|
9
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
12
|
-
module.exports = /*#__PURE__*/function () {
|
|
13
|
-
function Errors() {
|
|
14
|
-
(0, _classCallCheck2["default"])(this, Errors);
|
|
15
|
-
}
|
|
16
|
-
return (0, _createClass2["default"])(Errors, [{
|
|
17
|
-
key: "catch",
|
|
18
|
-
value:
|
|
19
|
-
/**
|
|
20
|
-
* Wraps the given promise so that errors caught preserve the stack trace of the calling thread.
|
|
21
|
-
*
|
|
22
|
-
* The example compares the stack trace of a rejected promise using this method and the stack trace of a rejected promise that does not use this method.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* const errors = require("@util.js/errors");
|
|
26
|
-
* function rejectAPromise() {
|
|
27
|
-
* return Promise.reject(new TypeError("Fail!"));
|
|
28
|
-
* }
|
|
29
|
-
*
|
|
30
|
-
* errors
|
|
31
|
-
* .catch(rejectAPromise())
|
|
32
|
-
* .catch(error => console.log("\n\nWith Caller Stack Trace\n" + error.stack));
|
|
33
|
-
* // With Caller Stack Trace
|
|
34
|
-
* // AsyncError: Fail!
|
|
35
|
-
* // at promise.catch.error (/root/utiljs/packages/utiljs-errors/lib/Errors.js:28:13)
|
|
36
|
-
* // at process._tickCallback (internal/process/next_tick.js:68:7)
|
|
37
|
-
* // at Function.Module.runMain (internal/modules/cjs/loader.js:746:11)
|
|
38
|
-
* // at startup (internal/bootstrap/node.js:240:19)
|
|
39
|
-
* // at bootstrapNodeJSCore (internal/bootstrap/node.js:564:3)
|
|
40
|
-
* // at runExample0 (/root/utiljs/packages/utiljs-errors/doc/README-examples.js:23:11)
|
|
41
|
-
* // at runExample (/root/utiljs/packages/utiljs-errors/doc/README-examples.js:12:7)
|
|
42
|
-
* // at Object.<anonymous> (/root/utiljs/packages/utiljs-errors/doc/README-examples.js:4:31)
|
|
43
|
-
* // at Module._compile (internal/modules/cjs/loader.js:702:30)
|
|
44
|
-
* // at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
|
|
45
|
-
* // at Module.load (internal/modules/cjs/loader.js:612:32)
|
|
46
|
-
* // at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
|
|
47
|
-
* // at Function.Module._load (internal/modules/cjs/loader.js:543:3)
|
|
48
|
-
* // at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
|
|
49
|
-
* // TypeError: Fail!
|
|
50
|
-
* // at rejectAPromise (/root/utiljs/packages/utiljs-errors/doc/README-examples.js:20:27)
|
|
51
|
-
* // at runExample0 (/root/utiljs/packages/utiljs-errors/doc/README-examples.js:23:12)
|
|
52
|
-
* // at runExample (/root/utiljs/packages/utiljs-errors/doc/README-examples.js:12:7)
|
|
53
|
-
* // at Object.<anonymous> (/root/utiljs/packages/utiljs-errors/doc/README-examples.js:4:31)
|
|
54
|
-
* // at Module._compile (internal/modules/cjs/loader.js:702:30)
|
|
55
|
-
* // at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
|
|
56
|
-
* // at Module.load (internal/modules/cjs/loader.js:612:32)
|
|
57
|
-
* // at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
|
|
58
|
-
* // at Function.Module._load (internal/modules/cjs/loader.js:543:3)
|
|
59
|
-
* // at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
|
|
60
|
-
*
|
|
61
|
-
* rejectAPromise().catch(error =>
|
|
62
|
-
* console.log("\n\nWithout Caller Stack Trace\n" + error.stack)
|
|
63
|
-
* );
|
|
64
|
-
* // Without Caller Stack Trace
|
|
65
|
-
* // TypeError: Fail!
|
|
66
|
-
* // at rejectAPromise (/root/utiljs/packages/utiljs-errors/doc/README-examples.js:20:27)
|
|
67
|
-
* // at runExample0 (/root/utiljs/packages/utiljs-errors/doc/README-examples.js:53:3)
|
|
68
|
-
* // at runExample (/root/utiljs/packages/utiljs-errors/doc/README-examples.js:12:7)
|
|
69
|
-
* // at Object.<anonymous> (/root/utiljs/packages/utiljs-errors/doc/README-examples.js:4:31)
|
|
70
|
-
* // at Module._compile (internal/modules/cjs/loader.js:702:30)
|
|
71
|
-
* // at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
|
|
72
|
-
* // at Module.load (internal/modules/cjs/loader.js:612:32)
|
|
73
|
-
* // at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
|
|
74
|
-
* // at Function.Module._load (internal/modules/cjs/loader.js:543:3)
|
|
75
|
-
* // at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
|
|
76
|
-
*
|
|
77
|
-
* @param {Promise} promise The promise to wrap
|
|
78
|
-
* @param {String} [message] A human-readable description of the error
|
|
79
|
-
* @return {Promise} A promise that upon rejection wraps the error in an AsyncError and rethrows
|
|
80
|
-
* @throws {TypeError} If the given promise is not an instance of Promise
|
|
81
|
-
*
|
|
82
|
-
* @public
|
|
83
|
-
* @function Errors#catch
|
|
84
|
-
*/
|
|
85
|
-
function _catch(promise, message) {
|
|
86
|
-
var _this = this;
|
|
87
|
-
var callerError = new Error();
|
|
88
|
-
return promise["catch"](function (error) {
|
|
89
|
-
throw new _this.AsyncError(callerError, error, message);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* An error that preserves the stack trace of the thread that calls an asynchronous function.
|
|
95
|
-
*
|
|
96
|
-
* Use {@link Errors#catch} to use this class. Use this class directly for instanceof checks.
|
|
97
|
-
*
|
|
98
|
-
* @public
|
|
99
|
-
* @class Errors#AsyncError
|
|
100
|
-
*/
|
|
101
|
-
}, {
|
|
102
|
-
key: "AsyncError",
|
|
103
|
-
get: function get() {
|
|
104
|
-
return require("./AsyncError");
|
|
105
|
-
}
|
|
106
|
-
}, {
|
|
107
|
-
key: "FalsyError",
|
|
108
|
-
get: function get() {
|
|
109
|
-
return require("./FalsyError");
|
|
110
|
-
}
|
|
111
|
-
}, {
|
|
112
|
-
key: "MissingError",
|
|
113
|
-
get: function get() {
|
|
114
|
-
return require("./MissingError");
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* A wrapper of another error used for rethrowing.
|
|
119
|
-
*
|
|
120
|
-
* This error preserves information about the original error and its stack trace.
|
|
121
|
-
*
|
|
122
|
-
* A [Stack Overflow]{@link https://stackoverflow.com/questions/42754270/re-throwing-exception-in-nodejs-and-not-losing-stack-trace} article inspired this class.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* function throwATypeError() {
|
|
126
|
-
* throw new TypeError("Invalid Argument");
|
|
127
|
-
* }
|
|
128
|
-
*
|
|
129
|
-
* function rethrowTheTypeError() {
|
|
130
|
-
* try {
|
|
131
|
-
* throwATypeError();
|
|
132
|
-
* } catch (error) {
|
|
133
|
-
* throw new RethrownError(error, "Lorem Ipsum");
|
|
134
|
-
* }
|
|
135
|
-
* }
|
|
136
|
-
*
|
|
137
|
-
* try {
|
|
138
|
-
* rethrowTheTypeError();
|
|
139
|
-
* } catch (error) {
|
|
140
|
-
* console.log(error.stack);
|
|
141
|
-
* // This outputs a stack trace like the following:
|
|
142
|
-
* //
|
|
143
|
-
* // RethrownError: Lorem Ipsum
|
|
144
|
-
* // at rethrowTheTypeError (/root/utiljs/packages/utiljs-errors/test/ErrorsTest.js:16:15)
|
|
145
|
-
* // TypeError: Invalid Argument
|
|
146
|
-
* // at throwATypeError (/root/utiljs/packages/utiljs-errors/test/ErrorsTest.js:10:13)
|
|
147
|
-
* // at rethrowTheTypeError (/root/utiljs/packages/utiljs-errors/test/ErrorsTest.js:14:9)
|
|
148
|
-
* // at Context.it (/root/utiljs/packages/utiljs-errors/test/ErrorsTest.js:20:7)
|
|
149
|
-
* // ...
|
|
150
|
-
* }
|
|
151
|
-
*
|
|
152
|
-
* @param {Error} error The error to rethrow
|
|
153
|
-
* @param {String} [message] A human-readable description of the error
|
|
154
|
-
* @throws {TypeError} if the given error is not defined
|
|
155
|
-
*
|
|
156
|
-
* @public
|
|
157
|
-
* @class Errors#RethrownError
|
|
158
|
-
*/
|
|
159
|
-
}, {
|
|
160
|
-
key: "RethrownError",
|
|
161
|
-
get: function get() {
|
|
162
|
-
return require("./RethrownError");
|
|
163
|
-
}
|
|
164
|
-
}]);
|
|
165
|
-
}();
|
package/dist/FalsyError.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
6
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
7
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
8
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
9
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
10
|
-
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
|
|
11
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
12
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
|
-
module.exports = /*#__PURE__*/function (_TypeError) {
|
|
14
|
-
function FalsyError(argumentValue, argumentName, functionName) {
|
|
15
|
-
var _this;
|
|
16
|
-
(0, _classCallCheck2["default"])(this, FalsyError);
|
|
17
|
-
_this = _callSuper(this, FalsyError, [argumentValue ? "Why are you creating a FalsyError with a truthy `argumentValue`: '" + argumentValue + "'?" : (functionName || "We") + " expected " + (argumentName ? "`" + argumentName + "`" : "an argument") + " to be truthy. " + (argumentName ? "`" + argumentName + "`" : "It") + " is the falsy value " + (argumentValue === "" ? "''" : argumentValue) + "."]);
|
|
18
|
-
_this.name = _this.constructor.name;
|
|
19
|
-
_this.argumentName = argumentName;
|
|
20
|
-
return _this;
|
|
21
|
-
}
|
|
22
|
-
(0, _inherits2["default"])(FalsyError, _TypeError);
|
|
23
|
-
return (0, _createClass2["default"])(FalsyError, null, [{
|
|
24
|
-
key: "check",
|
|
25
|
-
value: function check(argumentValue, argumentName, functionName) {
|
|
26
|
-
if (argumentValue) return;
|
|
27
|
-
throw new FalsyError(argumentValue, argumentName, functionName);
|
|
28
|
-
}
|
|
29
|
-
}]);
|
|
30
|
-
}(/*#__PURE__*/(0, _wrapNativeSuper2["default"])(TypeError));
|
package/dist/MissingError.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
6
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
7
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
8
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
9
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
10
|
-
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
|
|
11
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
12
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
|
-
module.exports = /*#__PURE__*/function (_TypeError) {
|
|
14
|
-
function MissingError(argumentValue, argumentName, functionName) {
|
|
15
|
-
var _this;
|
|
16
|
-
(0, _classCallCheck2["default"])(this, MissingError);
|
|
17
|
-
_this = _callSuper(this, MissingError, [argumentValue != null ? "Why are you creating a MissingError with a defined `argumentValue`: '" + argumentValue + "'?" : (functionName || "We") + " expected " + (argumentName ? "`" + argumentName + "`" : "an argument") + " to be defined. " + (argumentName ? "`" + argumentName + "`" : "It") + " is '" + argumentValue + "'."]);
|
|
18
|
-
_this.name = _this.constructor.name;
|
|
19
|
-
_this.argumentName = argumentName;
|
|
20
|
-
return _this;
|
|
21
|
-
}
|
|
22
|
-
(0, _inherits2["default"])(MissingError, _TypeError);
|
|
23
|
-
return (0, _createClass2["default"])(MissingError, null, [{
|
|
24
|
-
key: "check",
|
|
25
|
-
value: function check(argumentValue, argumentName, functionName) {
|
|
26
|
-
if (argumentValue != null) return;
|
|
27
|
-
throw new MissingError(argumentValue, argumentName, functionName);
|
|
28
|
-
}
|
|
29
|
-
}]);
|
|
30
|
-
}(/*#__PURE__*/(0, _wrapNativeSuper2["default"])(TypeError));
|
package/dist/RethrownError.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* See {@link Errors#RethrownError}.
|
|
5
|
-
*/
|
|
6
|
-
var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
|
|
7
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
8
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
9
|
-
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
11
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
12
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
13
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
14
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
15
|
-
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
|
|
16
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
17
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
18
|
-
module.exports = /*#__PURE__*/function (_Error) {
|
|
19
|
-
function RethrownError(error, message) {
|
|
20
|
-
var _context;
|
|
21
|
-
var _this;
|
|
22
|
-
(0, _classCallCheck2["default"])(this, RethrownError);
|
|
23
|
-
_this = _callSuper(this, RethrownError, [message != null ? message : getErrorProperty(error, "message")]);
|
|
24
|
-
if (!error) throw new TypeError("RethrownError's constructor expects a defined error, but it was ".concat(error, "."));
|
|
25
|
-
_this.name = _this.constructor.name;
|
|
26
|
-
_this.original = error;
|
|
27
|
-
_this.newStack = _this.stack;
|
|
28
|
-
var errorStack = getErrorProperty(error, "stack");
|
|
29
|
-
_this.stack = (0, _concat["default"])(_context = "".concat(_this.stack, "\n")).call(_context, errorStack);
|
|
30
|
-
return _this;
|
|
31
|
-
}
|
|
32
|
-
(0, _inherits2["default"])(RethrownError, _Error);
|
|
33
|
-
return (0, _createClass2["default"])(RethrownError);
|
|
34
|
-
}(/*#__PURE__*/(0, _wrapNativeSuper2["default"])(Error));
|
|
35
|
-
function getErrorProperty(error, property) {
|
|
36
|
-
if (error[property]) return error[property];
|
|
37
|
-
try {
|
|
38
|
-
return (0, _stringify["default"])(error);
|
|
39
|
-
} catch (e) {
|
|
40
|
-
// JSON.stringify might throw the following, "TypeError: Converting circular
|
|
41
|
-
// structure to JSON."
|
|
42
|
-
return error;
|
|
43
|
-
}
|
|
44
|
-
}
|