summaryrefslogtreecommitdiffstats
path: root/node_modules/create-error-class/index.js
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/create-error-class/index.js
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/create-error-class/index.js')
-rw-r--r--node_modules/create-error-class/index.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/node_modules/create-error-class/index.js b/node_modules/create-error-class/index.js
new file mode 100644
index 0000000..e415aa7
--- /dev/null
+++ b/node_modules/create-error-class/index.js
@@ -0,0 +1,44 @@
+'use strict';
+var captureStackTrace = require('capture-stack-trace');
+
+function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+}
+
+module.exports = function createErrorClass(className, setup) {
+ if (typeof className !== 'string') {
+ throw new TypeError('Expected className to be a string');
+ }
+
+ if (/[^0-9a-zA-Z_$]/.test(className)) {
+ throw new Error('className contains invalid characters');
+ }
+
+ setup = setup || function (message) {
+ this.message = message;
+ };
+
+ var ErrorClass = function () {
+ Object.defineProperty(this, 'name', {
+ configurable: true,
+ value: className,
+ writable: true
+ });
+
+ captureStackTrace(this, this.constructor);
+
+ setup.apply(this, arguments);
+ };
+
+ inherits(ErrorClass, Error);
+
+ return ErrorClass;
+};