normalize-exception
Advanced tools
Comparing version 2.6.0 to 2.7.0
@@ -0,1 +1,2 @@ | ||
import isErrorInstance from"is-error-instance"; | ||
import isPlainObj from"is-plain-obj"; | ||
@@ -15,4 +16,4 @@ | ||
if(!isError(value)){ | ||
return handleNonError(value); | ||
if(!isErrorInstance(value)){ | ||
return stringifyError(value); | ||
} | ||
@@ -36,27 +37,16 @@ | ||
const isError=function(value){ | ||
try{ | ||
const isInvalidError=function(value){ | ||
return( | ||
objectToString.call(value)==="[object Error]"&& | ||
!(Symbol.toStringTag in value)); | ||
isProxy(value)|| | ||
isNonModifiableError(value)|| | ||
hasInvalidConstructor(value)); | ||
}catch{ | ||
return false; | ||
} | ||
}; | ||
const handleNonError=function(value){ | ||
return isProxy(value)?objectifyError(value):stringifyError(value); | ||
}; | ||
const isProxy=function(value){ | ||
try{ | ||
return value instanceof Error; | ||
return objectToString.call(value)==="[object Object]"; | ||
}catch{ | ||
@@ -67,8 +57,4 @@ return true; | ||
const isInvalidError=function(value){ | ||
return isNonModifiableError(value)||hasInvalidConstructor(value); | ||
}; | ||
const hasInvalidConstructor=function(error){ | ||
@@ -75,0 +61,0 @@ return( |
{ | ||
"name": "normalize-exception", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"type": "module", | ||
@@ -49,4 +49,4 @@ "exports": "./build/src/main.js", | ||
"devDependencies": { | ||
"@ehmicky/dev-tasks": "^1.0.88", | ||
"test-each": "^5.4.0" | ||
"@ehmicky/dev-tasks": "^1.0.94", | ||
"test-each": "^5.4.1" | ||
}, | ||
@@ -57,4 +57,5 @@ "engines": { | ||
"dependencies": { | ||
"is-error-instance": "^1.1.0", | ||
"is-plain-obj": "^4.1.0" | ||
} | ||
} |
@@ -363,2 +363,4 @@ [![Codecov](https://img.shields.io/codecov/c/github/ehmicky/normalize-exception.svg?label=tested&logo=codecov)](https://codecov.io/gh/ehmicky/normalize-exception) | ||
error with its `cause` | ||
- [`is-error-instance`](https://github.com/ehmicky/is-error-instance): Check if | ||
a value is an `Error` instance | ||
- [`set-error-class`](https://github.com/ehmicky/set-error-class): Properly | ||
@@ -365,0 +367,0 @@ update an error's class |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
405
35280
2
6193
423
+ Addedis-error-instance@^1.1.0
+ Addedis-error-instance@1.6.0(transitive)