@naturalcycles/js-lib 14.70.0 → 14.70.1
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/dist/error/error.util.js
CHANGED
|
@@ -67,6 +67,8 @@ function _errorObjectToAppError(o) {
|
|
|
67
67
|
}
|
|
68
68
|
exports._errorObjectToAppError = _errorObjectToAppError;
|
|
69
69
|
function _errorObjectToError(o, errorClass = Error) {
|
|
70
|
+
if (o instanceof errorClass)
|
|
71
|
+
return o;
|
|
70
72
|
const err = new errorClass(o.message);
|
|
71
73
|
// name: err.name, // cannot be assigned to a readonly property like this
|
|
72
74
|
// stack: o.stack, // also readonly e.g in Firefox
|
|
@@ -58,6 +58,8 @@ export function _errorObjectToAppError(o) {
|
|
|
58
58
|
return _errorObjectToError(o, AppError);
|
|
59
59
|
}
|
|
60
60
|
export function _errorObjectToError(o, errorClass = Error) {
|
|
61
|
+
if (o instanceof errorClass)
|
|
62
|
+
return o;
|
|
61
63
|
const err = new errorClass(o.message);
|
|
62
64
|
// name: err.name, // cannot be assigned to a readonly property like this
|
|
63
65
|
// stack: o.stack, // also readonly e.g in Firefox
|
package/package.json
CHANGED
package/src/error/error.util.ts
CHANGED
|
@@ -97,6 +97,8 @@ export function _errorObjectToError<DATA_TYPE, ERROR_TYPE extends Error>(
|
|
|
97
97
|
o: ErrorObject<DATA_TYPE>,
|
|
98
98
|
errorClass: Class<ERROR_TYPE> = Error as any,
|
|
99
99
|
): ERROR_TYPE {
|
|
100
|
+
if (o instanceof errorClass) return o
|
|
101
|
+
|
|
100
102
|
const err = new errorClass(o.message)
|
|
101
103
|
// name: err.name, // cannot be assigned to a readonly property like this
|
|
102
104
|
// stack: o.stack, // also readonly e.g in Firefox
|