modern-errors
Advanced tools
Comparing version 5.5.4 to 6.0.0
@@ -31,5 +31,5 @@ import errorCustomClass from"error-custom-class"; | ||
plugins, | ||
opts); | ||
opts | ||
); | ||
super(message,nativeOpts); | ||
@@ -42,3 +42,3 @@ | ||
return error; | ||
return error | ||
} | ||
@@ -58,3 +58,2 @@ } | ||
}); | ||
export default ModernError; | ||
//# sourceMappingURL=main.js.map | ||
export default ModernError; |
@@ -14,11 +14,10 @@ import{setNonEnumProp}from"../utils/descriptors.js"; | ||
if(errors===undefined){ | ||
return; | ||
return | ||
} | ||
if(!Array.isArray(errors)){ | ||
throw new TypeError(`"errors" option must be an array: ${errors}`); | ||
throw new TypeError(`"errors" option must be an array: ${errors}`) | ||
} | ||
setNonEnumProp(error,"errors",errors); | ||
}; | ||
//# sourceMappingURL=aggregate.js.map | ||
setNonEnumProp(error,"errors",errors) | ||
}; |
@@ -12,3 +12,3 @@ import isErrorInstance from"is-error-instance"; | ||
error.wrap=true; | ||
return mergeErrorCause(error); | ||
return mergeErrorCause(error) | ||
}; | ||
@@ -30,3 +30,3 @@ | ||
if(!isErrorInstance(error.cause)){ | ||
return mergeErrorCause(error); | ||
return mergeErrorCause(error) | ||
} | ||
@@ -37,6 +37,6 @@ | ||
if(!shouldPrefixCause(error,ErrorClass)){ | ||
return mergeErrorCause(error); | ||
return mergeErrorCause(error) | ||
} | ||
return mergePrefixedError(error); | ||
return mergePrefixedError(error) | ||
}; | ||
@@ -50,7 +50,6 @@ | ||
if(cause!==errorA){ | ||
undoPrefixCause(cause,oldMessage); | ||
undoPrefixCause(cause,oldMessage) | ||
} | ||
return errorA; | ||
}; | ||
//# sourceMappingURL=cause.js.map | ||
return errorA | ||
}; |
@@ -19,3 +19,3 @@ import setErrorMessage from"set-error-message"; | ||
hasValidName(cause)&&( | ||
hasUsefulName(cause,ErrorClass)||cause.name!==cause.constructor.name)); | ||
hasUsefulName(cause,ErrorClass)||cause.name!==cause.constructor.name)) | ||
@@ -43,3 +43,3 @@ }; | ||
setErrorMessage(cause,newMessage); | ||
return oldMessage; | ||
return oldMessage | ||
}; | ||
@@ -49,4 +49,3 @@ | ||
export const undoPrefixCause=(cause,oldMessage)=>{ | ||
setErrorMessage(cause,oldMessage); | ||
}; | ||
//# sourceMappingURL=prefix.js.map | ||
setErrorMessage(cause,oldMessage) | ||
}; |
@@ -13,7 +13,7 @@ import isPlainObj from"is-plain-obj"; | ||
throw new TypeError( | ||
`The second argument of "${ParentError.name}.subclass()" must be a plain object, not: ${classOpts}`); | ||
`The second argument of "${ParentError.name}.subclass()" must be a plain object, not: ${classOpts}` | ||
) | ||
} | ||
return classOpts; | ||
return classOpts | ||
}; | ||
@@ -36,6 +36,5 @@ | ||
plugins.forEach((plugin)=>{ | ||
getPluginOpts({pluginsOpts:classOptsB,plugin,full:false}); | ||
getPluginOpts({pluginsOpts:classOptsB,plugin,full:false}) | ||
}); | ||
return classOptsB; | ||
}; | ||
//# sourceMappingURL=class.js.map | ||
return classOptsB | ||
}; |
@@ -18,10 +18,10 @@ import isPlainObj from"is-plain-obj"; | ||
if(Array.isArray(value)){ | ||
return value.map(deepClone); | ||
return value.map(deepClone) | ||
} | ||
if(isPlainObj(value)){ | ||
return deepCloneObject(value); | ||
return deepCloneObject(value) | ||
} | ||
return value; | ||
return value | ||
}; | ||
@@ -37,7 +37,6 @@ | ||
Object.defineProperty(copy,key,{...descriptor,value:childCopy}); | ||
Object.defineProperty(copy,key,{...descriptor,value:childCopy}) | ||
} | ||
return copy; | ||
}; | ||
//# sourceMappingURL=clone.js.map | ||
return copy | ||
}; |
@@ -16,4 +16,4 @@ import{mergeSpecificCause}from"../merge/cause.js"; | ||
throw new Error( | ||
`The plugin "${fullName}" does not have any options: ${options}`); | ||
`The plugin "${fullName}" does not have any options: ${options}` | ||
) | ||
} | ||
@@ -29,7 +29,6 @@ }; | ||
try{ | ||
return getOptions(pluginsOpts[name],full); | ||
return getOptions(pluginsOpts[name],full) | ||
}catch(cause){ | ||
throw mergeSpecificCause(new Error(`Invalid "${name}" options:`),cause); | ||
throw mergeSpecificCause(new Error(`Invalid "${name}" options:`),cause) | ||
} | ||
}; | ||
//# sourceMappingURL=get.js.map | ||
}; |
@@ -16,3 +16,3 @@ import{excludeKeys,includeKeys}from"filter-obj"; | ||
const pluginsOptsA=wrapPluginsOpts(plugins,pluginsOpts,nativeOpts); | ||
return{nativeOpts,errors,pluginsOpts:pluginsOptsA}; | ||
return{nativeOpts,errors,pluginsOpts:pluginsOptsA} | ||
}; | ||
@@ -35,4 +35,4 @@ | ||
throw new TypeError( | ||
`Error options must be a plain object or undefined: ${opts}`); | ||
`Error options must be a plain object or undefined: ${opts}` | ||
) | ||
} | ||
@@ -42,4 +42,4 @@ | ||
throw new TypeError( | ||
`Error option "custom" must be passed to "${ErrorClass.name}.subclass()", not to error constructors.`); | ||
`Error option "custom" must be passed to "${ErrorClass.name}.subclass()", not to error constructors.` | ||
) | ||
} | ||
@@ -54,3 +54,3 @@ }; | ||
if(!instancesData.has(cause)){ | ||
return pluginsOpts; | ||
return pluginsOpts | ||
} | ||
@@ -60,4 +60,3 @@ | ||
const pluginsOptsA=mergePluginsOpts(causePluginsOpts,pluginsOpts,plugins); | ||
return deepClone(pluginsOptsA); | ||
}; | ||
//# sourceMappingURL=instance.js.map | ||
return deepClone(pluginsOptsA) | ||
}; |
@@ -23,8 +23,8 @@ import isPlainObj from"is-plain-obj"; | ||
map((name)=>mergePluginOpts(oldOpts,newOpts,name)). | ||
filter(Boolean)); | ||
filter(Boolean) | ||
); | ||
const mergePluginOpts=(oldOpts,newOpts,name)=>{ | ||
const pluginOpt=mergeOpt(oldOpts[name],newOpts[name]); | ||
return pluginOpt===undefined?undefined:[name,pluginOpt]; | ||
return pluginOpt===undefined?undefined:[name,pluginOpt] | ||
}; | ||
@@ -34,10 +34,10 @@ | ||
if(newOpt===undefined){ | ||
return oldOpt; | ||
return oldOpt | ||
} | ||
if(isPlainObj(oldOpt)&&isPlainObj(newOpt)){ | ||
return{...oldOpt,...newOpt}; | ||
return{...oldOpt,...newOpt} | ||
} | ||
return newOpt; | ||
return newOpt | ||
}; | ||
@@ -47,3 +47,2 @@ | ||
const getPluginName=({name})=>name; | ||
//# sourceMappingURL=merge.js.map | ||
const getPluginName=({name})=>name; |
@@ -33,3 +33,3 @@ import{mergePluginsOpts}from"./merge.js"; | ||
if(args.length===0){ | ||
return{args}; | ||
return{args} | ||
} | ||
@@ -40,3 +40,3 @@ | ||
{args:args.slice(0,-1),methodOpts:{[plugin.name]:lastArg}}: | ||
{args}; | ||
{args} | ||
}; | ||
@@ -49,7 +49,7 @@ | ||
throw new TypeError( | ||
`The plugin "${fullName}"'s "isOptions()" method must return a boolean, not: ${typeof isOptionsResult}`); | ||
`The plugin "${fullName}"'s "isOptions()" method must return a boolean, not: ${typeof isOptionsResult}` | ||
) | ||
} | ||
return isOptionsResult; | ||
return isOptionsResult | ||
}; | ||
@@ -60,3 +60,2 @@ | ||
pluginsOpts: | ||
mergePluginsOpts(pluginsOpts,methodOpts,plugins); | ||
//# sourceMappingURL=method.js.map | ||
mergePluginsOpts(pluginsOpts,methodOpts,plugins); |
@@ -50,4 +50,3 @@ import{deepClone}from"./clone.js"; | ||
}); | ||
return options; | ||
}; | ||
//# sourceMappingURL=plugins.js.map | ||
return options | ||
}; |
@@ -5,3 +5,2 @@ import PROPS_PLUGIN from"./props/main.js"; | ||
export const CORE_PLUGINS=[PROPS_PLUGIN]; | ||
//# sourceMappingURL=main.js.map | ||
export const CORE_PLUGINS=[PROPS_PLUGIN]; |
@@ -6,3 +6,3 @@ import isPlainObj from"is-plain-obj"; | ||
if(!isPlainObj(options)){ | ||
throw new TypeError(`It must be a plain object: ${options}`); | ||
throw new TypeError(`It must be a plain object: ${options}`) | ||
} | ||
@@ -12,3 +12,3 @@ | ||
const{message,...optionsA}=options; | ||
return optionsA; | ||
return optionsA | ||
}; | ||
@@ -24,3 +24,2 @@ | ||
properties | ||
}; | ||
//# sourceMappingURL=main.js.map | ||
}; |
@@ -20,3 +20,3 @@ import{mergePluginsOpts}from"../../options/merge.js"; | ||
const info=getKnownErrorInfo({error:errorA,methodOpts,plugins,plugin}); | ||
return{...info,error:errorA}; | ||
return{...info,error:errorA} | ||
}; | ||
@@ -37,3 +37,3 @@ | ||
}); | ||
return{ErrorClass,ErrorClasses,options}; | ||
return{ErrorClass,ErrorClasses,options} | ||
}; | ||
@@ -48,4 +48,3 @@ | ||
const{subclasses}=classesData.get(ErrorClass); | ||
return[ErrorClass,...subclasses]; | ||
}; | ||
//# sourceMappingURL=error.js.map | ||
return[ErrorClass,...subclasses] | ||
}; |
@@ -23,3 +23,3 @@ import{instancesData}from"../../subclass/map.js"; | ||
Object.assign(info,{error}); | ||
return info; | ||
return info | ||
}; | ||
@@ -44,3 +44,3 @@ | ||
setInstancesData(info); | ||
return info; | ||
return info | ||
}; | ||
@@ -57,4 +57,3 @@ | ||
configurable:true | ||
}); | ||
}; | ||
//# sourceMappingURL=main.js.map | ||
}) | ||
}; |
@@ -16,7 +16,7 @@ import{getMethodOpts}from"../../options/method.js"; | ||
throw new TypeError( | ||
`Missing "this" context: "${methodName}()" must be called using "error.${methodName}()"`); | ||
`Missing "this" context: "${methodName}()" must be called using "error.${methodName}()"` | ||
) | ||
} | ||
return callMethod({methodFunc,plugin,plugins,error,args}); | ||
return callMethod({methodFunc,plugin,plugins,error,args}) | ||
}; | ||
@@ -27,4 +27,3 @@ | ||
const info=getErrorPluginInfo({error,methodOpts,plugins,plugin}); | ||
return methodFunc(info,...argsA); | ||
}; | ||
//# sourceMappingURL=call.js.map | ||
return methodFunc(info,...argsA) | ||
}; |
@@ -10,4 +10,4 @@ import{setNonEnumProp}from"../../utils/descriptors.js"; | ||
plugins.forEach((plugin)=>{ | ||
addInstanceMethods(plugin,plugins,ErrorClass); | ||
}); | ||
addInstanceMethods(plugin,plugins,ErrorClass) | ||
}) | ||
}; | ||
@@ -17,4 +17,4 @@ | ||
Object.entries(plugin.instanceMethods).forEach( | ||
addInstanceMethod.bind(undefined,{plugin,plugins,ErrorClass})); | ||
addInstanceMethod.bind(undefined,{plugin,plugins,ErrorClass}) | ||
) | ||
}; | ||
@@ -39,5 +39,5 @@ | ||
args | ||
}); | ||
}); | ||
}) | ||
} | ||
); | ||
setNonEnumProp( | ||
@@ -51,4 +51,4 @@ ErrorClass, | ||
ErrorClass | ||
})); | ||
}) | ||
) | ||
}; | ||
@@ -61,3 +61,2 @@ | ||
const getPluginMethodNames=({instanceMethods})=> | ||
Object.keys(instanceMethods); | ||
//# sourceMappingURL=main.js.map | ||
Object.keys(instanceMethods); |
@@ -17,4 +17,3 @@ import{callMethod}from"./call.js"; | ||
const errorA=ErrorClass.normalize(error); | ||
return callMethod({methodFunc,plugin,plugins,error:errorA,args}); | ||
}; | ||
//# sourceMappingURL=mixed.js.map | ||
return callMethod({methodFunc,plugin,plugins,error:errorA,args}) | ||
}; |
@@ -26,11 +26,11 @@ import{excludeKeys}from"filter-obj"; | ||
if(stack!==undefined){ | ||
setErrorStack(error,stack); | ||
setErrorStack(error,stack) | ||
} | ||
if(message!==undefined){ | ||
setErrorMessage(error,message); | ||
setErrorMessage(error,message) | ||
} | ||
if(Reflect.ownKeys(newProps).length===0){ | ||
return; | ||
return | ||
} | ||
@@ -40,8 +40,7 @@ | ||
...OMITTED_PROPS, | ||
...getPluginsMethodNames(plugins)]); | ||
setErrorProps(error,keys); | ||
...getPluginsMethodNames(plugins)] | ||
); | ||
setErrorProps(error,keys) | ||
}; | ||
const OMITTED_PROPS=["wrap","constructorArgs"]; | ||
//# sourceMappingURL=assign.js.map | ||
const OMITTED_PROPS=["wrap","constructorArgs"]; |
@@ -20,3 +20,3 @@ import isPlainObj from"is-plain-obj"; | ||
plugins.forEach((plugin)=>{ | ||
applyPluginProperties({error,plugin,plugins}); | ||
applyPluginProperties({error,plugin,plugins}) | ||
}); | ||
@@ -31,3 +31,3 @@ | ||
if(properties===undefined){ | ||
return; | ||
return | ||
} | ||
@@ -40,8 +40,7 @@ | ||
throw new TypeError( | ||
`Plugin "${fullName}"'s "properties()" must return a plain object: ${newProps}`); | ||
`Plugin "${fullName}"'s "properties()" must return a plain object: ${newProps}` | ||
) | ||
} | ||
assignError(error,newProps,plugins); | ||
}; | ||
//# sourceMappingURL=main.js.map | ||
assignError(error,newProps,plugins) | ||
}; |
@@ -12,4 +12,4 @@ | ||
throw new TypeError( | ||
`The plugin "${fullName}" must not define "${duplicateName}()" as both "instanceMethods" and "staticMethods".`); | ||
`The plugin "${fullName}" must not define "${duplicateName}()" as both "instanceMethods" and "staticMethods".` | ||
) | ||
} | ||
@@ -22,4 +22,4 @@ }; | ||
plugins.forEach((pluginA,indexA)=>{ | ||
validateDuplicatePlugin({pluginA,indexA,plugins,ParentError}); | ||
}); | ||
validateDuplicatePlugin({pluginA,indexA,plugins,ParentError}) | ||
}) | ||
}; | ||
@@ -29,4 +29,4 @@ | ||
plugins.forEach((pluginB,indexB)=>{ | ||
validateEachPlugin({pluginA,pluginB,indexA,indexB,ParentError}); | ||
}); | ||
validateEachPlugin({pluginA,pluginB,indexA,indexB,ParentError}) | ||
}) | ||
}; | ||
@@ -42,3 +42,3 @@ | ||
if(indexA===indexB){ | ||
return; | ||
return | ||
} | ||
@@ -48,4 +48,4 @@ | ||
throw new TypeError( | ||
`The "plugins" option of "${ParentError.name}.subclass()" must not include "${pluginA.fullName}": this plugin has already been included.`); | ||
`The "plugins" option of "${ParentError.name}.subclass()" must not include "${pluginA.fullName}": this plugin has already been included.` | ||
) | ||
} | ||
@@ -55,9 +55,9 @@ | ||
{...pluginA.instanceMethods,...pluginA.staticMethods}, | ||
{...pluginB.instanceMethods,...pluginB.staticMethods}); | ||
{...pluginB.instanceMethods,...pluginB.staticMethods} | ||
); | ||
if(duplicateName!==undefined){ | ||
throw new TypeError( | ||
`The plugins "${pluginA.fullName}" and "${pluginB.fullName}" must not both define the same "${duplicateName}()" method.`); | ||
`The plugins "${pluginA.fullName}" and "${pluginB.fullName}" must not both define the same "${duplicateName}()" method.` | ||
) | ||
} | ||
@@ -68,4 +68,3 @@ }; | ||
const keysA=Object.keys(objectA); | ||
return Object.keys(objectB).find((key)=>keysA.includes(key)); | ||
}; | ||
//# sourceMappingURL=duplicate.js.map | ||
return Object.keys(objectB).find((key)=>keysA.includes(key)) | ||
}; |
@@ -15,7 +15,7 @@ import isPlainObj from"is-plain-obj"; | ||
const pluginsB=pluginsA.map((plugin)=> | ||
normalizePlugin(plugin,ParentError)); | ||
normalizePlugin(plugin,ParentError) | ||
); | ||
const pluginsC=[...parentPlugins,...pluginsB]; | ||
validateDuplicatePlugins(pluginsC,ParentError); | ||
return pluginsC; | ||
return pluginsC | ||
}; | ||
@@ -26,7 +26,7 @@ | ||
throw new TypeError( | ||
`The "plugins" option of "${ParentError.name}.subclass()" must be an array: ${plugins}`); | ||
`The "plugins" option of "${ParentError.name}.subclass()" must be an array: ${plugins}` | ||
) | ||
} | ||
return plugins; | ||
return plugins | ||
}; | ||
@@ -37,4 +37,4 @@ | ||
throw new TypeError( | ||
`The "plugins" option of "${ParentError.name}.subclass()" must be an array of plugin objects: ${plugin}`); | ||
`The "plugins" option of "${ParentError.name}.subclass()" must be an array of plugin objects: ${plugin}` | ||
) | ||
} | ||
@@ -48,3 +48,3 @@ | ||
const pluginD=normalizeGetOptions({plugin:pluginC}); | ||
return pluginD; | ||
return pluginD | ||
}; | ||
@@ -54,4 +54,4 @@ | ||
OPTIONAL_FUNCS.forEach((funcName)=>{ | ||
validateOptionalFunc(plugin,funcName); | ||
}); | ||
validateOptionalFunc(plugin,funcName) | ||
}) | ||
}; | ||
@@ -66,6 +66,5 @@ | ||
throw new TypeError( | ||
`The plugin "${plugin.fullName}"'s "${funcName}()" property must be either undefined or a function, not: ${funcValue}`); | ||
`The plugin "${plugin.fullName}"'s "${funcName}()" property must be either undefined or a function, not: ${funcValue}` | ||
) | ||
} | ||
}; | ||
//# sourceMappingURL=main.js.map | ||
}; |
@@ -20,3 +20,3 @@ import isPlainObj from"is-plain-obj"; | ||
}); | ||
return pluginC; | ||
return pluginC | ||
}; | ||
@@ -47,4 +47,4 @@ | ||
throw new TypeError( | ||
`The plugin "${plugin.fullName}"'s "${propName}" property must be either undefined or a plain object, not: ${methods}`); | ||
`The plugin "${plugin.fullName}"'s "${propName}" property must be either undefined or a plain object, not: ${methods}` | ||
) | ||
} | ||
@@ -61,5 +61,5 @@ | ||
forbiddenNames | ||
}) | ||
}); | ||
}); | ||
return{...plugin,[propName]:methods}; | ||
return{...plugin,[propName]:methods} | ||
}; | ||
@@ -78,4 +78,4 @@ | ||
throw new TypeError( | ||
`The plugin "${plugin.fullName}"'s "${propName}.${methodName}" property must be a function, not: ${methodValue}`); | ||
`The plugin "${plugin.fullName}"'s "${propName}.${methodName}" property must be a function, not: ${methodValue}` | ||
) | ||
} | ||
@@ -85,6 +85,5 @@ | ||
throw new TypeError( | ||
`The plugin "${plugin.fullName}"'s "${propName}.${methodName}" property name is invalid: "${coreObjectName}.${methodName}" already exists.`); | ||
`The plugin "${plugin.fullName}"'s "${propName}.${methodName}" property name is invalid: "${coreObjectName}.${methodName}" already exists.` | ||
) | ||
} | ||
}; | ||
//# sourceMappingURL=methods.js.map | ||
}; |
@@ -6,4 +6,4 @@ | ||
Object.entries(pluginsOpts).forEach(([optName,pluginOpts])=>{ | ||
validatePluginOptsName(optName,pluginOpts,plugins); | ||
}); | ||
validatePluginOptsName(optName,pluginOpts,plugins) | ||
}) | ||
}; | ||
@@ -14,4 +14,4 @@ | ||
throw new TypeError( | ||
`Invalid option "${optName}": the plugin "${NAME_PREFIX}${optName}" must be passed to ErrorClass.subclass("...", { plugins })`); | ||
`Invalid option "${optName}": the plugin "${NAME_PREFIX}${optName}" must be passed to ErrorClass.subclass("...", { plugins })` | ||
) | ||
} | ||
@@ -23,3 +23,3 @@ }; | ||
if(plugin.name===undefined){ | ||
throw new TypeError(`The plugin is missing a "name": ${plugin}`); | ||
throw new TypeError(`The plugin is missing a "name": ${plugin}`) | ||
} | ||
@@ -30,3 +30,3 @@ | ||
if(typeof name!=="string"){ | ||
throw new TypeError(`The plugin "name" must be a string: ${name}`); | ||
throw new TypeError(`The plugin "name" must be a string: ${name}`) | ||
} | ||
@@ -36,3 +36,3 @@ | ||
return{...plugin,fullName:`${NAME_PREFIX}${name}`}; | ||
return{...plugin,fullName:`${NAME_PREFIX}${name}`} | ||
}; | ||
@@ -43,4 +43,4 @@ | ||
throw new TypeError( | ||
`The plugin "name" must not be the following reserved word: ${name}`); | ||
`The plugin "name" must not be the following reserved word: ${name}` | ||
) | ||
} | ||
@@ -50,4 +50,4 @@ | ||
throw new TypeError( | ||
`The plugin "name" must only contain lowercase letters and digits: ${name}`); | ||
`The plugin "name" must only contain lowercase letters and digits: ${name}` | ||
) | ||
} | ||
@@ -61,8 +61,7 @@ }; | ||
"wrap", | ||
"constructorArgs"]); | ||
"constructorArgs"] | ||
); | ||
const NAME_REGEXP=/^[a-z][a-z\d]*$/u; | ||
const NAME_PREFIX="modern-errors-"; | ||
//# sourceMappingURL=name.js.map | ||
const NAME_PREFIX="modern-errors-"; |
@@ -26,4 +26,3 @@ import{getMethodOpts}from"../../options/method.js"; | ||
}); | ||
return methodFunc(info,...argsA); | ||
}; | ||
//# sourceMappingURL=call.js.map | ||
return methodFunc(info,...argsA) | ||
}; |
@@ -39,4 +39,4 @@ import{setNonEnumProp}from"../../utils/descriptors.js"; | ||
plugins.forEach((plugin)=>{ | ||
addStaticMethods(plugin,plugins,ErrorClass); | ||
}); | ||
addStaticMethods(plugin,plugins,ErrorClass) | ||
}) | ||
}; | ||
@@ -46,4 +46,4 @@ | ||
Object.entries(plugin.staticMethods).forEach( | ||
addStaticMethod.bind(undefined,{plugin,plugins,ErrorClass})); | ||
addStaticMethod.bind(undefined,{plugin,plugins,ErrorClass}) | ||
) | ||
}; | ||
@@ -63,5 +63,4 @@ | ||
ErrorClass | ||
})); | ||
}; | ||
//# sourceMappingURL=main.js.map | ||
}) | ||
) | ||
}; |
@@ -7,8 +7,8 @@ import{isSubclass}from"../utils/subclass.js"; | ||
throw new TypeError( | ||
`The "custom" class of "${ParentError.name}.subclass()" must be a class: ${custom}`); | ||
`The "custom" class of "${ParentError.name}.subclass()" must be a class: ${custom}` | ||
) | ||
} | ||
checkParent(custom,ParentError); | ||
checkPrototype(custom,ParentError); | ||
checkPrototype(custom,ParentError) | ||
}; | ||
@@ -27,4 +27,4 @@ | ||
throw new TypeError( | ||
`The "custom" class of "${ParentError.name}.subclass()" must extend from ${ParentError.name}, but not be ${ParentError.name} itself.`); | ||
`The "custom" class of "${ParentError.name}.subclass()" must extend from ${ParentError.name}, but not be ${ParentError.name} itself.` | ||
) | ||
} | ||
@@ -34,4 +34,4 @@ | ||
throw new TypeError( | ||
`The "custom" class of "${ParentError.name}.subclass()" must extend from ${ParentError.name}.`); | ||
`The "custom" class of "${ParentError.name}.subclass()" must extend from ${ParentError.name}.` | ||
) | ||
} | ||
@@ -41,4 +41,4 @@ | ||
throw new TypeError( | ||
`The "custom" class of "${ParentError.name}.subclass()" must extend directly from ${ParentError.name}.`); | ||
`The "custom" class of "${ParentError.name}.subclass()" must extend directly from ${ParentError.name}.` | ||
) | ||
} | ||
@@ -50,4 +50,4 @@ }; | ||
throw new TypeError( | ||
`The "custom" class's prototype of "${ParentError.name}.subclass()" is invalid: ${custom.prototype}`); | ||
`The "custom" class's prototype of "${ParentError.name}.subclass()" is invalid: ${custom.prototype}` | ||
) | ||
} | ||
@@ -57,6 +57,5 @@ | ||
throw new TypeError( | ||
`The "custom" class of "${ParentError.name}.subclass()" has an invalid "constructor" property.`); | ||
`The "custom" class of "${ParentError.name}.subclass()" has an invalid "constructor" property.` | ||
) | ||
} | ||
}; | ||
//# sourceMappingURL=check.js.map | ||
}; |
@@ -25,4 +25,4 @@ import{setErrorName}from"error-class-utils"; | ||
ParentError, | ||
classOpts); | ||
classOpts | ||
); | ||
const ErrorClass=getErrorClass(ParentError,custom); | ||
@@ -38,3 +38,3 @@ addParentSubclass(ErrorClass,ParentError); | ||
className | ||
}); | ||
}) | ||
}; | ||
@@ -48,3 +48,3 @@ | ||
subclasses:[...subclasses,ErrorClass] | ||
}); | ||
}) | ||
}; | ||
@@ -71,3 +71,3 @@ | ||
setClassMethods(ErrorClass,pluginsA); | ||
return ErrorClass; | ||
return ErrorClass | ||
}; | ||
@@ -80,7 +80,6 @@ | ||
"subclass", | ||
createSubclass.bind(undefined,ErrorClass)); | ||
createSubclass.bind(undefined,ErrorClass) | ||
); | ||
addAllInstanceMethods(plugins,ErrorClass); | ||
addAllStaticMethods(plugins,ErrorClass); | ||
}; | ||
//# sourceMappingURL=create.js.map | ||
addAllStaticMethods(plugins,ErrorClass) | ||
}; |
@@ -21,3 +21,3 @@ import{checkCustom}from"./check.js"; | ||
const ParentClass=getParentClass(ParentError,custom); | ||
return class extends ParentClass{}; | ||
return class extends ParentClass{} | ||
}; | ||
@@ -27,8 +27,7 @@ | ||
if(custom===undefined){ | ||
return ParentError; | ||
return ParentError | ||
} | ||
checkCustom(custom,ParentError); | ||
return custom; | ||
}; | ||
//# sourceMappingURL=custom.js.map | ||
return custom | ||
}; |
@@ -11,3 +11,2 @@ | ||
export const instancesData=new WeakMap; | ||
//# sourceMappingURL=map.js.map | ||
export const instancesData=new WeakMap; |
@@ -34,7 +34,7 @@ import normalizeException from"normalize-exception"; | ||
throw new TypeError( | ||
`${ErrorClass.name}.normalize()'s second argument should be a subclass of ${ErrorClass.name}, not: ${UnknownError}`); | ||
`${ErrorClass.name}.normalize()'s second argument should be a subclass of ${ErrorClass.name}, not: ${UnknownError}` | ||
) | ||
} | ||
return normalizeError({error,ErrorClass,UnknownError,parents:[]}); | ||
return normalizeError({error,ErrorClass,UnknownError,parents:[]}) | ||
}; | ||
@@ -46,3 +46,3 @@ | ||
normalizeException(error,{shallow:true}): | ||
new UnknownError("",{cause:error}); | ||
new UnknownError("",{cause:error}) | ||
}; | ||
@@ -60,3 +60,3 @@ | ||
if(!Array.isArray(error?.errors)){ | ||
return; | ||
return | ||
} | ||
@@ -73,5 +73,5 @@ | ||
parents:parentsA | ||
})); | ||
setNonEnumProp(error,"errors",errors); | ||
}) | ||
); | ||
setNonEnumProp(error,"errors",errors) | ||
}; | ||
@@ -81,3 +81,2 @@ | ||
error?.constructor===UnknownError|| | ||
error instanceof ErrorClass&&error.constructor!==ErrorClass; | ||
//# sourceMappingURL=normalize.js.map | ||
error instanceof ErrorClass&&error.constructor!==ErrorClass; |
@@ -16,3 +16,3 @@ import{classesData}from"./map.js"; | ||
if(classesData.has(ErrorClass)){ | ||
return; | ||
return | ||
} | ||
@@ -25,5 +25,4 @@ | ||
This error class should be created like this instead: | ||
export const ${name} = ${parentName}.subclass('${name}')`); | ||
}; | ||
//# sourceMappingURL=validate.js.map | ||
export const ${name} = ${parentName}.subclass('${name}')` | ||
) | ||
}; |
@@ -9,4 +9,3 @@ | ||
configurable:true | ||
}); | ||
}; | ||
//# sourceMappingURL=descriptors.js.map | ||
}) | ||
}; |
@@ -23,3 +23,2 @@ | ||
const{isPrototypeOf:isProtoOf}=Object.prototype; | ||
//# sourceMappingURL=subclass.js.map | ||
const{isPrototypeOf:isProtoOf}=Object.prototype; |
{ | ||
"name": "modern-errors", | ||
"version": "5.5.4", | ||
"version": "6.0.0", | ||
"type": "module", | ||
@@ -55,28 +55,28 @@ "exports": { | ||
"dependencies": { | ||
"error-class-utils": "^2.5.0", | ||
"error-custom-class": "^8.4.0", | ||
"error-class-utils": "^3.0.0", | ||
"error-custom-class": "^9.0.0", | ||
"filter-obj": "^5.1.0", | ||
"is-plain-obj": "^4.1.0", | ||
"merge-error-cause": "^3.5.0", | ||
"normalize-exception": "^2.11.0", | ||
"set-error-message": "^1.6.0", | ||
"set-error-props": "^4.0.0", | ||
"set-error-stack": "^1.0.0" | ||
"merge-error-cause": "^4.0.1", | ||
"normalize-exception": "^3.0.0", | ||
"set-error-message": "^2.0.1", | ||
"set-error-props": "^5.0.0", | ||
"set-error-stack": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ehmicky/dev-tasks": "^2.0.70", | ||
"is-error-instance": "^1.6.0", | ||
"modern-errors-bugs": "^2.1.0", | ||
"modern-errors-clean": "^3.1.0", | ||
"modern-errors-cli": "^2.3.0", | ||
"@ehmicky/dev-tasks": "^2.0.80", | ||
"is-error-instance": "^2.0.0", | ||
"modern-errors-bugs": "^3.0.0", | ||
"modern-errors-clean": "^4.0.0", | ||
"modern-errors-cli": "^3.0.0", | ||
"modern-errors-http": "^2.3.0", | ||
"modern-errors-process": "^2.1.0", | ||
"modern-errors-process": "^3.0.0", | ||
"modern-errors-serialize": "^3.0.0", | ||
"modern-errors-switch": "^1.0.1", | ||
"modern-errors-winston": "^2.3.0", | ||
"test-each": "^5.7.1" | ||
"modern-errors-winston": "^3.0.0", | ||
"test-each": "^6.0.1" | ||
}, | ||
"engines": { | ||
"node": ">=14.18.0" | ||
"node": ">=16.17.0" | ||
} | ||
} |
@@ -16,12 +16,2 @@ <picture> | ||
# Hire me | ||
Please | ||
[reach out](https://www.linkedin.com/feed/update/urn:li:activity:7018596298127781890/) | ||
if you're looking for a Node.js API or CLI engineer (10 years of experience). | ||
Most recently I have been [Netlify Build](https://github.com/netlify/build)'s | ||
and [Netlify Plugins](https://www.netlify.com/products/build/plugins/)' | ||
technical lead for 2.5 years. I am available for full-time remote positions in | ||
either US or EU time zones. | ||
# Features | ||
@@ -136,3 +126,3 @@ | ||
This package works in both Node.js >=14.18.0 and | ||
This package works in both Node.js >=16.17.0 and | ||
[browsers](https://raw.githubusercontent.com/ehmicky/dev-tasks/main/src/browserslist). | ||
@@ -139,0 +129,0 @@ |
2198
93279
720
+ Addederror-class-utils@3.0.0(transitive)
+ Addederror-custom-class@9.0.0(transitive)
+ Addedis-error-instance@2.0.0(transitive)
+ Addedmerge-error-cause@4.0.1(transitive)
+ Addednormalize-exception@3.0.0(transitive)
+ Addedredefine-property@2.0.0(transitive)
+ Addedset-error-class@2.0.0(transitive)
+ Addedset-error-message@2.0.1(transitive)
+ Addedset-error-props@5.0.0(transitive)
+ Addedset-error-stack@2.0.0(transitive)
+ Addedwrap-error-message@2.0.1(transitive)
- Removederror-class-utils@2.5.0(transitive)
- Removederror-custom-class@8.4.0(transitive)
- Removedis-error-instance@1.6.0(transitive)
- Removedmerge-error-cause@3.5.0(transitive)
- Removednormalize-exception@2.11.0(transitive)
- Removedredefine-property@1.0.2(transitive)
- Removedset-error-class@1.6.0(transitive)
- Removedset-error-message@1.6.0(transitive)
- Removedset-error-props@4.0.0(transitive)
- Removedset-error-stack@1.0.0(transitive)
- Removedwrap-error-message@1.0.0(transitive)
Updatederror-class-utils@^3.0.0
Updatederror-custom-class@^9.0.0
Updatedmerge-error-cause@^4.0.1
Updatednormalize-exception@^3.0.0
Updatedset-error-message@^2.0.1
Updatedset-error-props@^5.0.0
Updatedset-error-stack@^2.0.0