diff options
Diffstat (limited to 'bin/wiki/ImportarDesdeURL/node_modules/whoops/lib/create-error.js')
-rw-r--r-- | bin/wiki/ImportarDesdeURL/node_modules/whoops/lib/create-error.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/bin/wiki/ImportarDesdeURL/node_modules/whoops/lib/create-error.js b/bin/wiki/ImportarDesdeURL/node_modules/whoops/lib/create-error.js new file mode 100644 index 00000000..7ecc7a80 --- /dev/null +++ b/bin/wiki/ImportarDesdeURL/node_modules/whoops/lib/create-error.js @@ -0,0 +1,32 @@ +'use strict' + +const {inherits} = require('./helpers') +const mimicFn = require('mimic-fn') + +const REGEX_CLASS_NAME = /[^0-9a-zA-Z_$]/ + +function createError (className) { + if (typeof className !== 'string') { + throw new TypeError('Expected className to be a string') + } + + if (REGEX_CLASS_NAME.test(className)) { + throw new Error('className contains invalid characters') + } + + function ErrorClass () { + Object.defineProperty(this, 'name', { + configurable: true, + value: className, + writable: true + }) + + Error.captureStackTrace(this, this.constructor) + } + + inherits(ErrorClass, Error) + mimicFn(ErrorClass, Error) + return ErrorClass +} + +module.exports = createError |