modern-errors
Advanced tools
Comparing version 4.1.0 to 4.1.1
@@ -17,3 +17,2 @@ import normalizeException from"normalize-exception"; | ||
export const normalizeCause=function({ | ||
@@ -20,0 +19,0 @@ message, |
@@ -11,3 +11,2 @@ import{computePluginsOpts}from"../options/instance.js"; | ||
import{getCause,mergeCause}from"./merge.js"; | ||
import{getShowStack}from"./stack.js"; | ||
@@ -43,3 +42,2 @@ | ||
const applyErrorLogic=function({ | ||
@@ -73,10 +71,4 @@ currentError, | ||
normalizeAggregateErrors(error,AnyError); | ||
const showStack=getShowStack({error,cause,errorData,ErrorClasses}); | ||
setConstructorArgs(error,constructorArgs); | ||
errorData.set(error,{ | ||
showStack, | ||
pluginsOpts, | ||
previousValues:[], | ||
newValues:[] | ||
}); | ||
errorData.set(error,{pluginsOpts,previousValues:[],newValues:[]}); | ||
const{previousValues,newValues}=setPluginsProperties({ | ||
@@ -89,5 +81,5 @@ error, | ||
}); | ||
errorData.set(error,{showStack,pluginsOpts,previousValues,newValues}); | ||
errorData.set(error,{pluginsOpts,previousValues,newValues}); | ||
return error; | ||
}; | ||
//# sourceMappingURL=modify.js.map |
@@ -17,3 +17,3 @@ import{mergeClassOpts}from"../../options/merge.js"; | ||
const errorA=AnyError.normalize(error); | ||
const{pluginsOpts,showStack}=errorData.get(errorA); | ||
const{pluginsOpts}=errorData.get(errorA); | ||
const pluginsOptsA=mergeClassOpts({ | ||
@@ -31,4 +31,4 @@ error:errorA, | ||
}); | ||
return{error:errorA,options,showStack}; | ||
return{error:errorA,options}; | ||
}; | ||
//# sourceMappingURL=error.js.map |
@@ -14,3 +14,3 @@ import{getErrorInfo}from"./error.js"; | ||
}){ | ||
const{options,showStack}=getErrorInfo( | ||
const{options}=getErrorInfo( | ||
{errorData,AnyError,ErrorClasses,methodOpts,plugins,plugin}, | ||
@@ -28,3 +28,3 @@ error); | ||
}); | ||
return{...info,error,showStack}; | ||
return{...info,error}; | ||
}; | ||
@@ -31,0 +31,0 @@ |
@@ -35,2 +35,10 @@ import{deepClone}from"../../utils/clone.js"; | ||
export const getAllValues=function(previousDescriptors,newDescriptors){ | ||
@@ -37,0 +45,0 @@ const changedKeys=getChangedKeys(previousDescriptors,newDescriptors); |
@@ -56,4 +56,4 @@ import isPlainObj from"is-plain-obj"; | ||
const normalizeMethods=function(plugin,propName){var _plugin$propName; | ||
const methods=(_plugin$propName=plugin[propName])!==null&&_plugin$propName!==void 0?_plugin$propName:{}; | ||
const normalizeMethods=function(plugin,propName){ | ||
const methods=plugin[propName]??{}; | ||
@@ -60,0 +60,0 @@ if(!isPlainObj(methods)){ |
@@ -46,30 +46,2 @@ import type { ErrorName } from 'error-custom-class' | ||
/** | ||
* Hints whether `error.stack` should be printed or not. | ||
* | ||
* This is `true` if the error (or one of its inner errors) is _unknown_, and | ||
* `false` otherwise. | ||
* | ||
* If a plugin prints `error.stack` optionally, `showStack` can be used as the | ||
* default value of a `stack` boolean option. This allows users to decide | ||
* whether to print `error.stack` or not, while still providing with a good | ||
* default behavior. | ||
* | ||
* @example | ||
* ```js | ||
* export default { | ||
* name: 'example', | ||
* getOptions(options) { | ||
* // ... | ||
* }, | ||
* instanceMethods: { | ||
* log({ error, showStack, options: { stack = showStack } }) { | ||
* console.log(stack ? error.stack : error.message) | ||
* }, | ||
* }, | ||
* } | ||
* ``` | ||
*/ | ||
readonly showStack: boolean | ||
/** | ||
* Reference to `AnyError`. This can be used to call `AnyError.normalize()` or | ||
@@ -126,4 +98,4 @@ * `error instanceof AnyError`. | ||
* errors.forEach((error) => { | ||
* const { showStack } = errorInfo(error) | ||
* console.log(showStack ? error.stack : error.message) | ||
* const { options } = errorInfo(error) | ||
* console.error(options.example?.stack ? error.stack : error.message) | ||
* }) | ||
@@ -160,3 +132,3 @@ * } | ||
*/ | ||
readonly staticMethods: Omit<CommonInfo, 'error' | 'showStack'> | ||
readonly staticMethods: Omit<CommonInfo, 'error'> | ||
@@ -163,0 +135,0 @@ /** |
{ | ||
"name": "modern-errors", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"type": "module", | ||
@@ -64,9 +64,9 @@ "exports": { | ||
"devDependencies": { | ||
"@ehmicky/dev-tasks": "^1.0.99", | ||
"@ehmicky/dev-tasks": "^1.0.102", | ||
"is-error-instance": "^1.2.0", | ||
"modern-errors-bugs": "^1.2.0", | ||
"modern-errors-bugs": "^1.3.0", | ||
"modern-errors-cli": "^1.3.1", | ||
"modern-errors-http": "^1.3.0", | ||
"modern-errors-http": "^1.4.0", | ||
"modern-errors-process": "^1.2.0", | ||
"modern-errors-serialize": "^1.2.0", | ||
"modern-errors-serialize": "^1.3.0", | ||
"modern-errors-stack": "^1.2.0", | ||
@@ -73,0 +73,0 @@ "modern-errors-winston": "^1.2.0", |
101224
63
2631