modern-errors
Advanced tools
Comparing version 5.4.0 to 5.5.0
@@ -12,3 +12,3 @@ import{setNonEnumProp}from"../utils/descriptors.js"; | ||
export const setAggregateErrors=function(error,errors){ | ||
export const setAggregateErrors=(error,errors)=>{ | ||
if(errors===undefined){ | ||
@@ -15,0 +15,0 @@ return; |
@@ -9,3 +9,3 @@ import isErrorInstance from"is-error-instance"; | ||
export const mergeSpecificCause=function(error,cause){ | ||
export const mergeSpecificCause=(error,cause)=>{ | ||
error.cause=cause; | ||
@@ -28,3 +28,3 @@ error.wrap=true; | ||
export const mergeCause=function(error,ErrorClass){ | ||
export const mergeCause=(error,ErrorClass)=>{ | ||
if(!isErrorInstance(error.cause)){ | ||
@@ -43,3 +43,3 @@ return mergeErrorCause(error); | ||
const mergePrefixedError=function(error){ | ||
const mergePrefixedError=(error)=>{ | ||
const{cause}=error; | ||
@@ -46,0 +46,0 @@ const oldMessage=prefixCause(cause); |
@@ -15,3 +15,3 @@ import setErrorMessage from"set-error-message"; | ||
export const shouldPrefixCause=function(error,ErrorClass){ | ||
export const shouldPrefixCause=(error,ErrorClass)=>{ | ||
const{cause}=error; | ||
@@ -24,13 +24,10 @@ return( | ||
const hasValidName=function(cause){ | ||
return( | ||
const hasValidName=(cause)=> | ||
typeof cause.name==="string"&& | ||
cause.name!==""&& | ||
typeof cause.constructor==="function"&& | ||
typeof cause.constructor.name==="string"); | ||
typeof cause.constructor.name==="string"; | ||
}; | ||
const hasUsefulName=function(cause,ErrorClass){ | ||
return!( | ||
const hasUsefulName=(cause,ErrorClass)=> | ||
!( | ||
isSubclass(cause.constructor,ErrorClass)|| | ||
@@ -40,6 +37,5 @@ isSubclass(ErrorClass,cause.constructor)|| | ||
}; | ||
export const prefixCause=function(cause){ | ||
export const prefixCause=(cause)=>{ | ||
const oldMessage=typeof cause.message==="string"?cause.message:""; | ||
@@ -53,5 +49,5 @@ const newMessage= | ||
export const undoPrefixCause=function(cause,oldMessage){ | ||
export const undoPrefixCause=(cause,oldMessage)=>{ | ||
setErrorMessage(cause,oldMessage); | ||
}; | ||
//# sourceMappingURL=prefix.js.map |
@@ -10,3 +10,3 @@ import isPlainObj from"is-plain-obj"; | ||
export const normalizeClassOpts=function(ParentError,classOpts={}){ | ||
export const normalizeClassOpts=(ParentError,classOpts={})=>{ | ||
if(!isPlainObj(classOpts)){ | ||
@@ -31,3 +31,3 @@ throw new TypeError( | ||
export const getClassOpts=function(parentOpts,classOpts,plugins){ | ||
export const getClassOpts=(parentOpts,classOpts,plugins)=>{ | ||
validatePluginsOptsNames(classOpts,plugins); | ||
@@ -34,0 +34,0 @@ const classOptsA=mergePluginsOpts(parentOpts,classOpts,plugins); |
@@ -16,3 +16,3 @@ import isPlainObj from"is-plain-obj"; | ||
export const deepClone=function(value){ | ||
export const deepClone=(value)=>{ | ||
if(Array.isArray(value)){ | ||
@@ -29,3 +29,3 @@ return value.map(deepClone); | ||
const deepCloneObject=function(object){ | ||
const deepCloneObject=(object)=>{ | ||
const copy={}; | ||
@@ -32,0 +32,0 @@ |
@@ -5,3 +5,3 @@ import{mergeSpecificCause}from"../merge/cause.js"; | ||
export const normalizeGetOptions=function({ | ||
export const normalizeGetOptions=({ | ||
plugin, | ||
@@ -12,7 +12,5 @@ plugin:{ | ||
} | ||
}){ | ||
return{...plugin,getOptions}; | ||
}; | ||
})=>({...plugin,getOptions}); | ||
const defaultGetOptions=function(fullName,options){ | ||
const defaultGetOptions=(fullName,options)=>{ | ||
if(options!==undefined){ | ||
@@ -26,7 +24,7 @@ throw new Error( | ||
export const getPluginOpts=function({ | ||
export const getPluginOpts=({ | ||
pluginsOpts, | ||
plugin:{name,getOptions}, | ||
full | ||
}){ | ||
})=>{ | ||
try{ | ||
@@ -33,0 +31,0 @@ return getOptions(pluginsOpts[name],full); |
@@ -10,3 +10,3 @@ import{excludeKeys,includeKeys}from"filter-obj"; | ||
export const computePluginsOpts=function(ErrorClass,plugins,opts={}){ | ||
export const computePluginsOpts=(ErrorClass,plugins,opts={})=>{ | ||
validateOpts(ErrorClass,opts); | ||
@@ -32,3 +32,3 @@ const{errors,...optsA}=opts; | ||
const validateOpts=function(ErrorClass,opts){ | ||
const validateOpts=(ErrorClass,opts)=>{ | ||
if(!isPlainObj(opts)){ | ||
@@ -51,3 +51,3 @@ throw new TypeError( | ||
const wrapPluginsOpts=function(plugins,pluginsOpts,{cause}){ | ||
const wrapPluginsOpts=(plugins,pluginsOpts,{cause})=>{ | ||
if(!instancesData.has(cause)){ | ||
@@ -54,0 +54,0 @@ return pluginsOpts; |
@@ -19,4 +19,4 @@ import isPlainObj from"is-plain-obj"; | ||
export const mergePluginsOpts=function(oldOpts,newOpts,plugins){ | ||
return Object.fromEntries( | ||
export const mergePluginsOpts=(oldOpts,newOpts,plugins)=> | ||
Object.fromEntries( | ||
getPluginNames(plugins). | ||
@@ -26,5 +26,4 @@ map((name)=>mergePluginOpts(oldOpts,newOpts,name)). | ||
}; | ||
const mergePluginOpts=function(oldOpts,newOpts,name){ | ||
const mergePluginOpts=(oldOpts,newOpts,name)=>{ | ||
const pluginOpt=mergeOpt(oldOpts[name],newOpts[name]); | ||
@@ -34,3 +33,3 @@ return pluginOpt===undefined?undefined:[name,pluginOpt]; | ||
const mergeOpt=function(oldOpt,newOpt){ | ||
const mergeOpt=(oldOpt,newOpt)=>{ | ||
if(newOpt===undefined){ | ||
@@ -47,9 +46,5 @@ return oldOpt; | ||
export const getPluginNames=function(plugins){ | ||
return plugins.map(getPluginName); | ||
}; | ||
export const getPluginNames=(plugins)=>plugins.map(getPluginName); | ||
const getPluginName=function({name}){ | ||
return name; | ||
}; | ||
const getPluginName=({name})=>name; | ||
//# sourceMappingURL=merge.js.map |
@@ -7,8 +7,6 @@ import{mergePluginsOpts}from"./merge.js"; | ||
export const normalizeIsOptions=function({ | ||
export const normalizeIsOptions=({ | ||
plugin, | ||
plugin:{getOptions,isOptions=()=>getOptions!==undefined} | ||
}){ | ||
return{...plugin,isOptions}; | ||
}; | ||
})=>({...plugin,isOptions}); | ||
@@ -34,3 +32,3 @@ | ||
export const getMethodOpts=function(args,plugin){ | ||
export const getMethodOpts=(args,plugin)=>{ | ||
if(args.length===0){ | ||
@@ -46,3 +44,3 @@ return{args}; | ||
const lastArgIsOptions=function({isOptions,fullName},lastArg){ | ||
const lastArgIsOptions=({isOptions,fullName},lastArg)=>{ | ||
const isOptionsResult=isOptions(lastArg); | ||
@@ -59,7 +57,6 @@ | ||
export const mergeMethodOpts=function(pluginsOpts,methodOpts,plugins){ | ||
return methodOpts===undefined? | ||
export const mergeMethodOpts=(pluginsOpts,methodOpts,plugins)=> | ||
methodOpts===undefined? | ||
pluginsOpts: | ||
mergePluginsOpts(pluginsOpts,methodOpts,plugins); | ||
}; | ||
//# sourceMappingURL=method.js.map |
@@ -37,3 +37,3 @@ import{deepClone}from"./clone.js"; | ||
export const finalizePluginsOpts=function({ | ||
export const finalizePluginsOpts=({ | ||
pluginsOpts, | ||
@@ -43,3 +43,3 @@ methodOpts, | ||
plugin | ||
}){ | ||
})=>{ | ||
const pluginsOptsA=mergeMethodOpts(pluginsOpts,methodOpts,plugins); | ||
@@ -46,0 +46,0 @@ const pluginsOptsB=deepClone(pluginsOptsA); |
import isPlainObj from"is-plain-obj"; | ||
const getOptions=function(options={}){ | ||
const getOptions=(options={})=>{ | ||
if(!isPlainObj(options)){ | ||
@@ -15,5 +15,3 @@ throw new TypeError(`It must be a plain object: ${options}`); | ||
const properties=function({options}){ | ||
return options; | ||
}; | ||
const properties=({options})=>options; | ||
@@ -20,0 +18,0 @@ |
@@ -14,5 +14,5 @@ import{mergePluginsOpts}from"../../options/merge.js"; | ||
export const getAnyErrorInfo=function( | ||
export const getAnyErrorInfo=( | ||
{ErrorClass,methodOpts,plugins,plugin}, | ||
error) | ||
error)=> | ||
{ | ||
@@ -25,8 +25,3 @@ const errorA=ErrorClass.normalize(error); | ||
export const getKnownErrorInfo=function({ | ||
error, | ||
methodOpts, | ||
plugins, | ||
plugin | ||
}){ | ||
export const getKnownErrorInfo=({error,methodOpts,plugins,plugin})=>{ | ||
const ErrorClass=error.constructor; | ||
@@ -51,3 +46,3 @@ const ErrorClasses=getSubclasses(ErrorClass); | ||
export const getSubclasses=function(ErrorClass){ | ||
export const getSubclasses=(ErrorClass)=>{ | ||
const{subclasses}=classesData.get(ErrorClass); | ||
@@ -54,0 +49,0 @@ return[ErrorClass,...subclasses]; |
@@ -7,3 +7,3 @@ import type { ErrorInstance } from '../../merge/cause.js' | ||
*/ | ||
interface CommonInfo { | ||
interface CommonInfo<Options = never> { | ||
/** | ||
@@ -42,3 +42,3 @@ * Normalized error instance. | ||
*/ | ||
readonly options: never | ||
readonly options: Options | ||
@@ -89,13 +89,9 @@ /** | ||
* staticMethods: { | ||
* getLogErrors({ errorInfo }) { | ||
* return function logErrors(errors) { | ||
* getLogErrors: | ||
* ({ errorInfo }) => | ||
* (errors) => { | ||
* errors.forEach((error) => { | ||
* const { options } = errorInfo(error) | ||
* console.error( | ||
* options.example?.stack | ||
* ? error.stack | ||
* : error.message | ||
* ) | ||
* console.error(options.example?.stack ? error.stack : error.message) | ||
* }) | ||
* } | ||
* }, | ||
@@ -116,7 +112,7 @@ * }, | ||
*/ | ||
export interface Info { | ||
export interface Info<Options = never> { | ||
/** | ||
* `info` object passed to `plugin.properties()` | ||
*/ | ||
readonly properties: CommonInfo | ||
readonly properties: CommonInfo<Options> | ||
@@ -126,3 +122,3 @@ /** | ||
*/ | ||
readonly instanceMethods: CommonInfo | ||
readonly instanceMethods: CommonInfo<Options> | ||
@@ -132,3 +128,3 @@ /** | ||
*/ | ||
readonly staticMethods: Omit<CommonInfo, 'error'> | ||
readonly staticMethods: Omit<CommonInfo<Options>, 'error'> | ||
@@ -138,3 +134,3 @@ /** | ||
*/ | ||
readonly errorInfo: Omit<CommonInfo, 'errorInfo'> | ||
readonly errorInfo: Omit<CommonInfo<Options>, 'errorInfo'> | ||
} | ||
@@ -141,0 +137,0 @@ |
@@ -7,8 +7,3 @@ import{instancesData}from"../../subclass/map.js"; | ||
export const getErrorPluginInfo=function({ | ||
error, | ||
methodOpts, | ||
plugins, | ||
plugin | ||
}){ | ||
export const getErrorPluginInfo=({error,methodOpts,plugins,plugin})=>{ | ||
const{ErrorClass,options}=getKnownErrorInfo({ | ||
@@ -33,3 +28,3 @@ error, | ||
export const getPluginInfo=function({ | ||
export const getPluginInfo=({ | ||
options, | ||
@@ -40,3 +35,3 @@ ErrorClass, | ||
plugin | ||
}){ | ||
})=>{ | ||
const errorInfo=getAnyErrorInfo.bind(undefined,{ | ||
@@ -56,3 +51,3 @@ ErrorClass, | ||
const setInstancesData=function(info){ | ||
const setInstancesData=(info)=>{ | ||
@@ -59,0 +54,0 @@ Object.defineProperty(info,"instancesData",{ |
@@ -5,3 +5,3 @@ import{getMethodOpts}from"../../options/method.js"; | ||
export const callInstanceMethod=function({ | ||
export const callInstanceMethod=({ | ||
error, | ||
@@ -14,3 +14,3 @@ methodFunc, | ||
args | ||
}){ | ||
})=>{ | ||
if(!(error instanceof ErrorClass)){ | ||
@@ -25,9 +25,3 @@ throw new TypeError( | ||
export const callMethod=function({ | ||
methodFunc, | ||
plugin, | ||
plugins, | ||
error, | ||
args | ||
}){ | ||
export const callMethod=({methodFunc,plugin,plugins,error,args})=>{ | ||
const{args:argsA,methodOpts}=getMethodOpts(args,plugin); | ||
@@ -34,0 +28,0 @@ const info=getErrorPluginInfo({error,methodOpts,plugins,plugin}); |
@@ -8,3 +8,3 @@ import{setNonEnumProp}from"../../utils/descriptors.js"; | ||
export const addAllInstanceMethods=function(plugins,ErrorClass){ | ||
export const addAllInstanceMethods=(plugins,ErrorClass)=>{ | ||
plugins.forEach((plugin)=>{ | ||
@@ -15,3 +15,3 @@ addInstanceMethods(plugin,plugins,ErrorClass); | ||
const addInstanceMethods=function(plugin,plugins,ErrorClass){ | ||
const addInstanceMethods=(plugin,plugins,ErrorClass)=>{ | ||
Object.entries(plugin.instanceMethods).forEach( | ||
@@ -22,5 +22,5 @@ addInstanceMethod.bind(undefined,{plugin,plugins,ErrorClass})); | ||
const addInstanceMethod=function( | ||
const addInstanceMethod=( | ||
{plugin,plugins,ErrorClass}, | ||
[methodName,methodFunc]) | ||
[methodName,methodFunc])=> | ||
{ | ||
@@ -56,9 +56,7 @@ setNonEnumProp( | ||
export const getPluginsMethodNames=function(plugins){ | ||
return plugins.flatMap(getPluginMethodNames); | ||
}; | ||
export const getPluginsMethodNames=(plugins)=> | ||
plugins.flatMap(getPluginMethodNames); | ||
const getPluginMethodNames=function({instanceMethods}){ | ||
return Object.keys(instanceMethods); | ||
}; | ||
const getPluginMethodNames=({instanceMethods})=> | ||
Object.keys(instanceMethods); | ||
//# sourceMappingURL=main.js.map |
@@ -11,6 +11,6 @@ import{callMethod}from"./call.js"; | ||
export const callMixedMethod=function( | ||
export const callMixedMethod=( | ||
{methodFunc,plugin,plugins,ErrorClass}, | ||
error, | ||
...args) | ||
...args)=> | ||
{ | ||
@@ -17,0 +17,0 @@ const errorA=ErrorClass.normalize(error); |
@@ -20,6 +20,6 @@ import{excludeKeys}from"filter-obj"; | ||
export const assignError=function( | ||
export const assignError=( | ||
error, | ||
{message,stack,...newProps}, | ||
plugins) | ||
plugins)=> | ||
{ | ||
@@ -26,0 +26,0 @@ if(stack!==undefined){ |
@@ -18,9 +18,8 @@ import isPlainObj from"is-plain-obj"; | ||
export const setPluginsProperties=function(error,plugins){ | ||
return plugins.forEach((plugin)=>{ | ||
export const setPluginsProperties=(error,plugins)=> | ||
plugins.forEach((plugin)=>{ | ||
applyPluginProperties({error,plugin,plugins}); | ||
}); | ||
}; | ||
const applyPluginProperties=function({ | ||
const applyPluginProperties=({ | ||
error, | ||
@@ -30,3 +29,3 @@ plugin, | ||
plugins | ||
}){ | ||
})=>{ | ||
if(properties===undefined){ | ||
@@ -33,0 +32,0 @@ return; |
export const validateSameMethods=function({ | ||
export const validateSameMethods=({ | ||
instanceMethods, | ||
staticMethods, | ||
fullName | ||
}){ | ||
})=>{ | ||
const duplicateName=findDuplicateKey(staticMethods,instanceMethods); | ||
@@ -19,3 +19,3 @@ | ||
export const validateDuplicatePlugins=function(plugins,ParentError){ | ||
export const validateDuplicatePlugins=(plugins,ParentError)=>{ | ||
plugins.forEach((pluginA,indexA)=>{ | ||
@@ -26,8 +26,3 @@ validateDuplicatePlugin({pluginA,indexA,plugins,ParentError}); | ||
const validateDuplicatePlugin=function({ | ||
pluginA, | ||
indexA, | ||
plugins, | ||
ParentError | ||
}){ | ||
const validateDuplicatePlugin=({pluginA,indexA,plugins,ParentError})=>{ | ||
plugins.forEach((pluginB,indexB)=>{ | ||
@@ -38,3 +33,3 @@ validateEachPlugin({pluginA,pluginB,indexA,indexB,ParentError}); | ||
const validateEachPlugin=function({ | ||
const validateEachPlugin=({ | ||
pluginA, | ||
@@ -45,3 +40,3 @@ pluginB, | ||
ParentError | ||
}){ | ||
})=>{ | ||
if(indexA===indexB){ | ||
@@ -69,3 +64,3 @@ return; | ||
const findDuplicateKey=function(objectA,objectB){ | ||
const findDuplicateKey=(objectA,objectB)=>{ | ||
const keysA=Object.keys(objectA); | ||
@@ -72,0 +67,0 @@ return Object.keys(objectB).find((key)=>keysA.includes(key)); |
@@ -12,3 +12,3 @@ import isPlainObj from"is-plain-obj"; | ||
export const normalizePlugins=function(parentPlugins,plugins,ParentError){ | ||
export const normalizePlugins=(parentPlugins,plugins,ParentError)=>{ | ||
const pluginsA=normalizePluginsOpt(ParentError,plugins); | ||
@@ -23,3 +23,3 @@ const pluginsB=pluginsA.map((plugin)=> | ||
const normalizePluginsOpt=function(ParentError,plugins=[]){ | ||
const normalizePluginsOpt=(ParentError,plugins=[])=>{ | ||
if(!Array.isArray(plugins)){ | ||
@@ -34,3 +34,3 @@ throw new TypeError( | ||
const normalizePlugin=function(plugin,ParentError){ | ||
const normalizePlugin=(plugin,ParentError)=>{ | ||
if(!isPlainObj(plugin)){ | ||
@@ -51,3 +51,3 @@ throw new TypeError( | ||
const validateOptionalFuncs=function(plugin){ | ||
const validateOptionalFuncs=(plugin)=>{ | ||
OPTIONAL_FUNCS.forEach((funcName)=>{ | ||
@@ -60,3 +60,3 @@ validateOptionalFunc(plugin,funcName); | ||
const validateOptionalFunc=function(plugin,funcName){ | ||
const validateOptionalFunc=(plugin,funcName)=>{ | ||
const funcValue=plugin[funcName]; | ||
@@ -63,0 +63,0 @@ |
import isPlainObj from"is-plain-obj"; | ||
export const normalizeAllMethods=function(plugin){ | ||
export const normalizeAllMethods=(plugin)=>{ | ||
const pluginA=normalizeMethods({ | ||
@@ -35,3 +35,3 @@ ...INSTANCE_METHODS, | ||
const normalizeMethods=function({ | ||
const normalizeMethods=({ | ||
plugin, | ||
@@ -42,3 +42,3 @@ propName, | ||
forbiddenNames | ||
}){ | ||
})=>{ | ||
const methods=plugin[propName]??{}; | ||
@@ -66,3 +66,3 @@ | ||
const validateMethod=function({ | ||
const validateMethod=({ | ||
methodValue, | ||
@@ -75,3 +75,3 @@ propName, | ||
forbiddenNames | ||
}){ | ||
})=>{ | ||
if(typeof methodValue!=="function"){ | ||
@@ -78,0 +78,0 @@ throw new TypeError( |
export const validatePluginsOptsNames=function(pluginsOpts,plugins){ | ||
export const validatePluginsOptsNames=(pluginsOpts,plugins)=>{ | ||
Object.entries(pluginsOpts).forEach(([optName,pluginOpts])=>{ | ||
@@ -10,3 +10,3 @@ validatePluginOptsName(optName,pluginOpts,plugins); | ||
const validatePluginOptsName=function(optName,pluginOpts,plugins){ | ||
const validatePluginOptsName=(optName,pluginOpts,plugins)=>{ | ||
if(!plugins.some(({name})=>name===optName)){ | ||
@@ -20,3 +20,3 @@ throw new TypeError( | ||
export const validatePluginName=function(plugin){ | ||
export const validatePluginName=(plugin)=>{ | ||
if(plugin.name===undefined){ | ||
@@ -37,3 +37,3 @@ throw new TypeError(`The plugin is missing a "name": ${plugin}`); | ||
const validateNameString=function(name){ | ||
const validateNameString=(name)=>{ | ||
if(FORBIDDEN_NAMES.has(name)){ | ||
@@ -40,0 +40,0 @@ throw new TypeError( |
@@ -7,5 +7,5 @@ import{getMethodOpts}from"../../options/method.js"; | ||
export const callStaticMethod=function( | ||
export const callStaticMethod=( | ||
{methodFunc,plugin,plugins,ErrorClass}, | ||
...args) | ||
...args)=> | ||
{ | ||
@@ -12,0 +12,0 @@ const{classOpts}=classesData.get(ErrorClass); |
@@ -37,3 +37,3 @@ import{setNonEnumProp}from"../../utils/descriptors.js"; | ||
export const addAllStaticMethods=function(plugins,ErrorClass){ | ||
export const addAllStaticMethods=(plugins,ErrorClass)=>{ | ||
plugins.forEach((plugin)=>{ | ||
@@ -44,3 +44,3 @@ addStaticMethods(plugin,plugins,ErrorClass); | ||
const addStaticMethods=function(plugin,plugins,ErrorClass){ | ||
const addStaticMethods=(plugin,plugins,ErrorClass)=>{ | ||
Object.entries(plugin.staticMethods).forEach( | ||
@@ -51,5 +51,5 @@ addStaticMethod.bind(undefined,{plugin,plugins,ErrorClass})); | ||
const addStaticMethod=function( | ||
const addStaticMethod=( | ||
{plugin,plugins,ErrorClass}, | ||
[methodName,methodFunc]) | ||
[methodName,methodFunc])=> | ||
{ | ||
@@ -56,0 +56,0 @@ setNonEnumProp( |
import{isSubclass}from"../utils/subclass.js"; | ||
export const checkCustom=function(custom,ParentError){ | ||
export const checkCustom=(custom,ParentError)=>{ | ||
if(typeof custom!=="function"){ | ||
@@ -23,3 +23,3 @@ throw new TypeError( | ||
const checkParent=function(custom,ParentError){ | ||
const checkParent=(custom,ParentError)=>{ | ||
if(custom===ParentError){ | ||
@@ -44,3 +44,3 @@ throw new TypeError( | ||
const checkPrototype=function(custom,ParentError){ | ||
const checkPrototype=(custom,ParentError)=>{ | ||
if(typeof custom.prototype!=="object"||custom.prototype===null){ | ||
@@ -47,0 +47,0 @@ throw new TypeError( |
@@ -20,3 +20,3 @@ import{setErrorName}from"error-class-utils"; | ||
export const createSubclass=function(ParentError,className,classOpts){ | ||
export const createSubclass=(ParentError,className,classOpts)=>{ | ||
const{classOpts:parentOpts,plugins:parentPlugins}= | ||
@@ -42,3 +42,3 @@ classesData.get(ParentError); | ||
const addParentSubclass=function(ErrorClass,ParentError){ | ||
const addParentSubclass=(ErrorClass,ParentError)=>{ | ||
const{subclasses,...classProps}=classesData.get(ParentError); | ||
@@ -52,3 +52,3 @@ classesData.set(ParentError,{ | ||
export const createClass=function({ | ||
export const createClass=({ | ||
ParentError, | ||
@@ -61,3 +61,3 @@ ErrorClass, | ||
className | ||
}){ | ||
})=>{ | ||
const pluginsA=normalizePlugins(parentPlugins,plugins,ParentError); | ||
@@ -75,3 +75,3 @@ const classOptsA=getClassOpts(parentOpts,classOpts,pluginsA); | ||
const setClassMethods=function(ErrorClass,plugins){ | ||
const setClassMethods=(ErrorClass,plugins)=>{ | ||
setNonEnumProp(ErrorClass,"normalize",normalize.bind(undefined,ErrorClass)); | ||
@@ -78,0 +78,0 @@ setNonEnumProp( |
@@ -19,3 +19,3 @@ import{checkCustom}from"./check.js"; | ||
export const getErrorClass=function(ParentError,custom){ | ||
export const getErrorClass=(ParentError,custom)=>{ | ||
const ParentClass=getParentClass(ParentError,custom); | ||
@@ -25,3 +25,3 @@ return class extends ParentClass{}; | ||
const getParentClass=function(ParentError,custom){ | ||
const getParentClass=(ParentError,custom)=>{ | ||
if(custom===undefined){ | ||
@@ -28,0 +28,0 @@ return ParentError; |
@@ -31,7 +31,3 @@ import normalizeException from"normalize-exception"; | ||
export const normalize=function( | ||
ErrorClass, | ||
error, | ||
UnknownError=ErrorClass) | ||
{ | ||
export const normalize=(ErrorClass,error,UnknownError=ErrorClass)=>{ | ||
if(!isSubclass(UnknownError,ErrorClass)){ | ||
@@ -46,3 +42,3 @@ throw new TypeError( | ||
const normalizeError=function({error,ErrorClass,UnknownError,parents}){ | ||
const normalizeError=({error,ErrorClass,UnknownError,parents})=>{ | ||
normalizeAggregateErrors({error,ErrorClass,UnknownError,parents}); | ||
@@ -57,3 +53,3 @@ return shouldKeepClass(error,ErrorClass,UnknownError)? | ||
const normalizeAggregateErrors=function({ | ||
const normalizeAggregateErrors=({ | ||
error, | ||
@@ -63,3 +59,3 @@ ErrorClass, | ||
parents | ||
}){ | ||
})=>{ | ||
if(!Array.isArray(error?.errors)){ | ||
@@ -83,8 +79,5 @@ return; | ||
const shouldKeepClass=function(error,ErrorClass,UnknownError){ | ||
return( | ||
const shouldKeepClass=(error,ErrorClass,UnknownError)=> | ||
error?.constructor===UnknownError|| | ||
error instanceof ErrorClass&&error.constructor!==ErrorClass); | ||
}; | ||
error instanceof ErrorClass&&error.constructor!==ErrorClass; | ||
//# sourceMappingURL=normalize.js.map |
@@ -14,3 +14,3 @@ import{classesData}from"./map.js"; | ||
export const validateSubclass=function(ErrorClass){ | ||
export const validateSubclass=(ErrorClass)=>{ | ||
if(classesData.has(ErrorClass)){ | ||
@@ -17,0 +17,0 @@ return; |
export const setNonEnumProp=function(object,propName,value){ | ||
export const setNonEnumProp=(object,propName,value)=>{ | ||
@@ -4,0 +4,0 @@ Object.defineProperty(object,propName,{ |
@@ -20,7 +20,6 @@ | ||
export const isSubclass=function(ErrorClass,ParentClass){ | ||
return ParentClass===ErrorClass||isProtoOf.call(ParentClass,ErrorClass); | ||
}; | ||
export const isSubclass=(ErrorClass,ParentClass)=> | ||
ParentClass===ErrorClass||isProtoOf.call(ParentClass,ErrorClass); | ||
const{isPrototypeOf:isProtoOf}=Object.prototype; | ||
//# sourceMappingURL=subclass.js.map |
{ | ||
"name": "modern-errors", | ||
"version": "5.4.0", | ||
"version": "5.5.0", | ||
"type": "module", | ||
@@ -52,4 +52,3 @@ "exports": { | ||
"example": "examples", | ||
"lib": "src", | ||
"test": "test" | ||
"lib": "src" | ||
}, | ||
@@ -68,7 +67,7 @@ "dependencies": { | ||
"devDependencies": { | ||
"@ehmicky/dev-tasks": "^2.0.52", | ||
"is-error-instance": "^1.5.0", | ||
"@ehmicky/dev-tasks": "^2.0.57", | ||
"is-error-instance": "^1.6.0", | ||
"modern-errors-bugs": "^2.1.0", | ||
"modern-errors-clean": "^3.1.0", | ||
"modern-errors-cli": "^2.2.0", | ||
"modern-errors-cli": "^2.3.0", | ||
"modern-errors-http": "^2.3.0", | ||
@@ -79,3 +78,3 @@ "modern-errors-process": "^2.1.0", | ||
"modern-errors-winston": "^2.3.0", | ||
"test-each": "^5.6.0" | ||
"test-each": "^5.7.1" | ||
}, | ||
@@ -82,0 +81,0 @@ "engines": { |
@@ -439,3 +439,3 @@ <picture> | ||
```js | ||
export const main = function () { | ||
export const main = () => { | ||
try { | ||
@@ -442,0 +442,0 @@ // ... |
92052
2178