normalize-exception
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -1,3 +0,1 @@ | ||
import safeJsonValue from"safe-json-value"; | ||
import{setErrorProperty}from"../descriptors.js"; | ||
@@ -33,10 +31,29 @@ import{setFullStack}from"../stack.js"; | ||
const getMessage=function(message,object){ | ||
if(typeof message==="string"&&message!==""){ | ||
return message; | ||
return typeof message==="string"&&message!==""? | ||
message: | ||
truncateMessage(safeJsonStringify(object)); | ||
}; | ||
const safeJsonStringify=function(object){ | ||
try{ | ||
return JSON.stringify(object); | ||
}catch{ | ||
return safeStringify(object); | ||
} | ||
}; | ||
const{value}=safeJsonValue(object,{maxSize:MESSAGE_MAX_SIZE}); | ||
return value===undefined?"Invalid error":JSON.stringify(value); | ||
const safeStringify=function(object){ | ||
try{ | ||
return String(object); | ||
}catch{ | ||
return"Invalid error"; | ||
} | ||
}; | ||
const truncateMessage=function(message){ | ||
return message.length<MESSAGE_MAX_SIZE? | ||
message: | ||
`${message.slice(0,MESSAGE_MAX_SIZE)}...`; | ||
}; | ||
const MESSAGE_MAX_SIZE=1e3; | ||
@@ -43,0 +60,0 @@ |
{ | ||
"name": "normalize-exception", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"type": "module", | ||
@@ -56,5 +56,4 @@ "exports": "./build/src/main.js", | ||
"dependencies": { | ||
"is-plain-obj": "^4.1.0", | ||
"safe-json-value": "^1.5.0" | ||
"is-plain-obj": "^4.1.0" | ||
} | ||
} |
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
33542
1
417
- Removedsafe-json-value@^1.5.0
- Removedis-error-instance@1.6.0(transitive)
- Removednormalize-exception@2.11.0(transitive)
- Removedsafe-json-value@1.11.0(transitive)