normalize-exception
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,2 +0,2 @@ | ||
import{setErrorProperty}from"./set.js"; | ||
import{setErrorProperty}from"./enumerable.js"; | ||
@@ -28,3 +28,6 @@ | ||
const isAggregateError=function(error){ | ||
return supportsAggregateError()&&error instanceof AggregateError; | ||
return( | ||
supportsAggregateError()&&( | ||
error.name==="AggregateError"||error instanceof AggregateError)); | ||
}; | ||
@@ -31,0 +34,0 @@ |
@@ -1,2 +0,2 @@ | ||
import{setErrorProperty}from"./set.js"; | ||
import{setErrorProperty}from"./enumerable.js"; | ||
@@ -3,0 +3,0 @@ |
import{supportsAggregateError}from"./aggregate.js"; | ||
import{setErrorProperty}from"./set.js"; | ||
import{setErrorProperty}from"./enumerable.js"; | ||
import{setFullStack}from"./stack.js"; | ||
import{isPlainObj}from"./utils.js"; | ||
export const createError=function(value){ | ||
return isPlainObj(value)?objectifyError(value):stringifyError(value); | ||
}; | ||
if(isPlainObj(value)){ | ||
return objectifyError(value); | ||
} | ||
const isPlainObj=function(value){ | ||
if(typeof value!=="object"||value===null){ | ||
return false; | ||
if(isError(value)){ | ||
return value; | ||
} | ||
const prototype=Object.getPrototypeOf(value); | ||
return prototype===Object.prototype||prototype===null; | ||
return stringifyError(value); | ||
}; | ||
const isError=function(value){ | ||
return objectToString.call(value)==="[object Error]"; | ||
}; | ||
const{toString:objectToString}=Object.prototype; | ||
const objectifyError=function({ | ||
@@ -21,0 +30,0 @@ name, |
import{normalizeAggregate}from"./aggregate.js"; | ||
import{normalizeCause}from"./cause.js"; | ||
import{createError}from"./create.js"; | ||
import{setErrorProperty}from"./set.js"; | ||
import{setErrorProperty,normalizeEnumerableProps}from"./enumerable.js"; | ||
import{setFullStack,fixStack}from"./stack.js"; | ||
@@ -20,12 +20,17 @@ | ||
const errorA=error instanceof Error?error:createError(error); | ||
normalizeName(errorA); | ||
normalizeMessage(errorA); | ||
normalizeStack(errorA); | ||
normalizeCause(errorA,recurse); | ||
normalizeAggregate(errorA,recurse); | ||
const errorA=createError(error); | ||
normalizeProps(errorA,recurse); | ||
return errorA; | ||
}; | ||
const normalizeProps=function(error,recurse){ | ||
normalizeName(error); | ||
normalizeMessage(error); | ||
normalizeStack(error); | ||
normalizeCause(error,recurse); | ||
normalizeAggregate(error,recurse); | ||
normalizeEnumerableProps(error); | ||
}; | ||
const normalizeName=function(error){ | ||
@@ -32,0 +37,0 @@ if(!isDefinedString(error.name)){ |
@@ -1,2 +0,2 @@ | ||
import{setErrorProperty}from"./set.js"; | ||
import{setErrorProperty}from"./enumerable.js"; | ||
@@ -3,0 +3,0 @@ |
{ | ||
"name": "normalize-exception", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "exports": "./build/src/main.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
47133
18
305