error-type
Advanced tools
Comparing version 1.1.9 to 1.1.10
@@ -12,2 +12,3 @@ import{defaultOnCreate,getOnCreateParams}from"./create.js"; | ||
export default function errorType(name,onCreate=defaultOnCreate){ | ||
@@ -14,0 +15,0 @@ const ErrorType=class extends Error{ |
@@ -19,2 +19,4 @@ import{setNonEnumProp}from"./set.js"; | ||
validateNativeErrors(name); | ||
if(!name.endsWith(ERROR_NAME_END)||name===ERROR_NAME_END){ | ||
@@ -27,2 +29,27 @@ throw new Error(`Error name "${name}" must end with "${ERROR_NAME_END}"`); | ||
const validateNativeErrors=function(errorName){ | ||
if(NATIVE_ERRORS.has(errorName)){ | ||
throw new Error(`Error name "${errorName}" must not be a native type.`); | ||
} | ||
}; | ||
const NATIVE_ERRORS=new Set([ | ||
"Error", | ||
"ReferenceError", | ||
"TypeError", | ||
"SyntaxError", | ||
"RangeError", | ||
"URIError", | ||
"EvalError", | ||
"AggregateError", | ||
"SystemError", | ||
"AssertionError", | ||
"DOMException"]); | ||
const validateErrorNamePattern=function(errorName){ | ||
@@ -38,6 +65,2 @@ if(errorName[0]!==errorName.toUpperCase()[0]){ | ||
} | ||
if(NATIVE_ERRORS.has(errorName)){ | ||
throw new Error(`Error name "${errorName}" must not be a native type.`); | ||
} | ||
}; | ||
@@ -47,12 +70,2 @@ | ||
const ERROR_NAME_REGEXP=/[A-Z][a-zA-Z]*Error$/u; | ||
const NATIVE_ERRORS=new Set([ | ||
"Error", | ||
"ReferenceError", | ||
"TypeError", | ||
"SyntaxError", | ||
"RangeError", | ||
"URIError", | ||
"EvalError", | ||
"AggregateError"]); | ||
//# sourceMappingURL=name.js.map |
{ | ||
"name": "error-type", | ||
"version": "1.1.9", | ||
"version": "1.1.10", | ||
"type": "module", | ||
@@ -49,4 +49,5 @@ "exports": "./build/src/main.js", | ||
"devDependencies": { | ||
"@ehmicky/dev-tasks": "^1.0.76", | ||
"@ehmicky/dev-tasks": "^1.0.77", | ||
"error-cause": "^1.0.4", | ||
"error-cause-polyfill": "^1.0.3", | ||
"test-each": "^5.0.0", | ||
@@ -53,0 +54,0 @@ "tsd": "^0.20.0" |
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
37903
180
5