summaryrefslogtreecommitdiffstats
path: root/node_modules/create-error-class
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
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')
-rw-r--r--node_modules/create-error-class/index.js44
-rw-r--r--node_modules/create-error-class/license21
-rw-r--r--node_modules/create-error-class/package.json60
-rw-r--r--node_modules/create-error-class/readme.md54
4 files changed, 179 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;
+};
diff --git a/node_modules/create-error-class/license b/node_modules/create-error-class/license
new file mode 100644
index 0000000..1aeb74f
--- /dev/null
+++ b/node_modules/create-error-class/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Vsevolod Strukchinsky <floatdrop@gmail.com> (github.com/floatdrop)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node_modules/create-error-class/package.json b/node_modules/create-error-class/package.json
new file mode 100644
index 0000000..f395a12
--- /dev/null
+++ b/node_modules/create-error-class/package.json
@@ -0,0 +1,60 @@
+{
+ "_from": "create-error-class@^3.0.0",
+ "_id": "create-error-class@3.0.2",
+ "_inBundle": false,
+ "_integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=",
+ "_location": "/create-error-class",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "create-error-class@^3.0.0",
+ "name": "create-error-class",
+ "escapedName": "create-error-class",
+ "rawSpec": "^3.0.0",
+ "saveSpec": null,
+ "fetchSpec": "^3.0.0"
+ },
+ "_requiredBy": [
+ "/got"
+ ],
+ "_resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz",
+ "_shasum": "06be7abef947a3f14a30fd610671d401bca8b7b6",
+ "_spec": "create-error-class@^3.0.0",
+ "_where": "/home/pruss/Dev/3-minute-website/node_modules/got",
+ "author": {
+ "name": "Vsevolod Strukchinsky",
+ "email": "floatdrop@gmail.com",
+ "url": "github.com/floatdrop"
+ },
+ "bugs": {
+ "url": "https://github.com/floatdrop/create-error-class/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "capture-stack-trace": "^1.0.0"
+ },
+ "deprecated": false,
+ "description": "Create Error classes",
+ "devDependencies": {
+ "mocha": "*"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/floatdrop/create-error-class#readme",
+ "keywords": [],
+ "license": "MIT",
+ "name": "create-error-class",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/floatdrop/create-error-class.git"
+ },
+ "scripts": {
+ "test": "mocha"
+ },
+ "version": "3.0.2"
+}
diff --git a/node_modules/create-error-class/readme.md b/node_modules/create-error-class/readme.md
new file mode 100644
index 0000000..d993cea
--- /dev/null
+++ b/node_modules/create-error-class/readme.md
@@ -0,0 +1,54 @@
+# create-error-class [![Build Status](https://travis-ci.org/floatdrop/create-error-class.svg?branch=master)](https://travis-ci.org/floatdrop/create-error-class)
+
+> Create error class
+
+
+## Install
+
+```
+$ npm install --save create-error-class
+```
+
+
+## Usage
+
+```js
+var createErrorClass = require('create-error-class');
+
+var HTTPError = createErrorClass('HTTPError', function (props) {
+ this.message = 'Status code is ' + props.statusCode;
+});
+
+throw new HTTPError({statusCode: 404});
+```
+
+
+## API
+
+### createErrorClass(className, [setup])
+
+Return constructor of Errors with `className`.
+
+#### className
+
+*Required*
+Type: `string`
+
+Class name of Error Object. Should contain characters from `[0-9a-zA-Z_$]` range.
+
+#### setup
+Type: `function`
+
+Setup function, that will be called after each Error object is created from constructor with context of Error object.
+
+By default `setup` function sets `this.message` as first argument:
+
+```js
+var MyError = createErrorClass('MyError');
+
+new MyError('Something gone wrong!').message; // => 'Something gone wrong!'
+```
+
+## License
+
+MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop)