Inital build
Some checks failed
Automated Container Build / build-and-push (push) Failing after 12s

This commit is contained in:
Elijah 2026-05-22 12:29:43 -07:00
parent fa2be029a2
commit 724d70e58b
3339 changed files with 1075535 additions and 0 deletions

135
frontend/node_modules/custom-error-instance/.npmignore generated vendored Normal file
View file

@ -0,0 +1,135 @@
# Created by .ignore support plugin (hsz.mobi)
### Windows template
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
### Linux template
*~
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
### OSX template
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Node template
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
node_modules

246
frontend/node_modules/custom-error-instance/README.md generated vendored Normal file
View file

@ -0,0 +1,246 @@
# custom-error-instance
## Why?
Errors are thrown when your code enters a state of instability, but depending on the error you may want to handle it differently. This module provides a way for you to define distinctive errors so that you can respond to them accordingly. See the *practical example* section for an example.
## About
Produce custom JavaScript errors that:
- Integrate seamlessly with NodeJS' existing Error implementation.
- Extend the Error object without altering it.
- Create an inheritance hierarchy of custom errors and sub custom errors.
- Have instanceof types and instance constructor names.
- Accept additional properties.
- Produce custom error output.
- Will produce a stack trace of the length you specify.
- Plugable, create your own error instance generators.
## Install
```sh
npm install custom-error-instance
```
## Basic Example
```js
var CustomError = require('custom-error-instance');
var e;
// define a custom error with a default message
var Parent = CustomError('ParentError', { message: 'Parent error' });
// define a custom error that inherits from the Parent custom error
var Child = CustomError('ChildError', Parent, { message: 'Child error' });
// create an error instance that uses defaults
e = Parent();
console.log(e.toString()); // "ParentError: Parent error"
console.log(e.message); // "Parent error"
console.log(e.name); // "ParentError"
console.log(e.constructor.name); // "ParentError"
console.log(e instanceof Parent); // true
console.log(e instanceof Error); // true
// create an error instance that overwrites the default message
e = Parent('Hello');
console.log(e.toString()); // "ParentError: Hello"
console.log(e.message); // "Hello"
console.log(e.name); // "ParentError"
console.log(e.constructor.name); // "ParentError"
console.log(e instanceof Parent); // true
console.log(e instanceof Error); // true
// create an error instance that overwrites the default message and defines a code
e = Parent({ message: 'Hello', code: 'XYZ' });
console.log(e.toString()); // "ParentError XYZ: Hello"
console.log(e.message); // "Hello"
console.log(e.name); // "ParentError"
console.log(e.constructor.name); // "ParentError"
console.log(e instanceof Parent); // true
console.log(e instanceof Error); // true
// create an error instance of the Child custom error
e = Child();
console.log(e.toString()); // "ParentError: Child error"
console.log(e.message); // "Child error"
console.log(e.name); // "ChildError"
console.log(e.constructor.name); // "ChildError"
console.log(e instanceof Child); // true
console.log(e instanceof Parent); // true
console.log(e instanceof Error); // true
```
## Practical Example
```js
var CustomError = require('custom-error-instance');
var store = {};
var Err = CustomError('MapError');
Err.inuse = CustomError(Err, { message: 'The specified key is already in use.', code: 'INUSE' });
function add(key, value) {
if (Math.random() < .3) throw new Err('Random Error');
if (store.hasOwnProperty(key)) throw new Err.inuse();
store[key] = value;
}
try {
add('x', 1);
add('x', 2);
} catch (e) {
if (e instanceof Err.inuse) {
console.error(e.toString()); // "MapError INUSE: The specified key is already in use."
} else if (e instanceof Err) {
console.error('Unexpected ' + e); // "Unexpected MapError: Random Error"
} else {
throw e;
}
}
```
## API
This module has just one function that is used to produce custom error constructors.
#### CustomError ( [ name ] [, parent ] [, properties ] [, factory ] )
Call this function to create a custom error constructor function.
**Parameters**
- **name** - an optional string that defines the name for the error. This name is also applied to the constructor name property. Defaults to `'Error'` or the name of the parent custom error.
- **parent** - an optional constructor function to inherit from. This function must be the `Error` function or a custom error constructor. Defaults to `Error`.
- **properties** - an optional object with properties and values that will be merged with any properties provided when an instance is created from this custom error constructor. Defaults to `{}`
- **factory** - an optional function to call to modify the properties of the custom error instance. If not provided and this constructor's parent is `Error` then the root factory will be used.
**Returns** a constructor function.
## Constructor Function
Defining a custom error returns a constructor function. You call the constructor to generate an `Error` instance.
```js
var myErrConstructor = CustomError('MyErr', { message: 'Error occurred' });
throw new myErrConstructor();
```
The constructor function takes two optional parameters:
1. **message** - This can be a string to fill the message property with or it can be an object that defines properties. Any properties defined here will overwrite properties specified when the constructor was being created by the `CustomError` function.
2. **config** - A configuration that can modify the behavior of the factory.
## Factories
A factory is used for modify the Error instance as it is being generated. By default the *root factory* will be applied to CustomError's that inherit directly from `Error`, but it is possible to specify the factory to call when you define a CustomError. When a factory is called, it is called with `this` being the `Error` or CustomError instance. The factory should modify `this` to make it into its desired state.
When a factory function is called it receives these parameters:
1. **properties** - The merged properties object (merging properties defined through CustomError inheritance with those provided when calling the constructor to create the instance).
2. **configuration** - An object that contains instructions for the factories to know how to run.
3. **factory** - An object with properties to call the factory functions defined at CustomError.factory. These functions, when called, will automatically scope the factory call to `this` and will automatically include the **factory** parameter as the third parameter.
### CustomError.factory
This object contains predefined factories that you can use to modify errors to some common formats. You can add, remove, or modify the functions on this object to define your own factory store.
Here are some of the defined factories that are already on the CustomError.factory object:
#### CustomError.factory.expectReceive
This factory calls the root factory and then appends to the current message string details about what was expected and what was recieved. In the following example the message and code are defined as defaults when we define the constructor. When the `Error` instance is created we define what was expected and what was received. The result is a nice and descriptive error message.
```js
var InvalidError = CustomError('InvalidError', { message: 'Invalid value.', code: 'EINVLD' }, CustomError.factory.expectReceive);
var e = new Err({ expected: 'a string', received: 5 });
console.log(e.toString()); // "InvalidError EINVLD: Invalid value. Expected a string. Received: 5"
```
#### CustomError.factory.root
Note: If a CustomError is being defined without specifying a factory and its parent is `Error` then the default root will be used. The root factory does the following:
1) Copies properties and their values onto the instance.
2) Generates a stack trace and stores it on the instance.
3) Creates message getter and setter on the instance.
4) Creates code getter and setter on the instance.
The configuration parameter for the factory takes the following properties:
- **rootOnly** - Set this to false to allow the root factory to run on CustomErrors that are not at the root (inheriting directly from `Error`). Defaults to `true`.
- **stackLength** - Specify the length of the stack trace for this error instance. Defaults to `10`.
## Inheritance
If a constructor is generated with a parent specified then the child constructor will inherit the default properties of the parent and will merge those with any properties that it defines. If the child constructor defines a factory too, then the parent's factory will be run before running the child's factory.
## Examples
**Example 1: Common Usage**
```js
var CustomError = require('custom-error-instance');
var MyErr = CustomError('MyError', { message: 'Default message' });
console.log(new MyError().toString()); // "MyError: Default Message";
console.log(new MyError('Oops').toString()); // "MyError: Oops";
console.log(new MyError({ message: 'Oops', code: 'EOOP' }).toString()); // "MyError EOOP: Oops"
```
**Example 2: Child Custom Error**
Child custom errors inherit properties and the factories from their parent custom error.
```js
var CustomError = require('custom-error-instance');
var MyErr = CustomError('MyError', { message: 'Parent message' });
var ChildError = CustomError('ChildError', MyErr, { message: 'Child message');
var e = new ChildError();
console.log(e.message); // "Child message";
console.log(e instanceof ChildError); // true
console.log(e instanceof MyErr); // true, through inheritance
console.log(e instanceof Error); // true, through inheritance
console.log(e.constructor.name); // "ChildError"
```
**Example 3: Default Properties**
```js
var CustomError = require('custom-error-instance');
var MyError = CustomError('MyError', { code: 'EMY', foo: 'bar' });
var e = new MyError('Oops');
console.log(e.message); // "Oops"
console.log(e.code); // 'EMY'
console.log(e.foo); // "bar"
```
**Example 4: Overwrite Default Properties**
```js
var CustomError = require('custom-error-instance');
var MyError = CustomError('MyError', { code: 'EMY', foo: 'bar' });
var e = new MyError({ message: 'Oops', code: 'FOO' });
console.log(e.message); // "Oops"
console.log(e.code); // 'FOO'
console.log(e.foo); // "bar"
```
**Example 5: Custom Factory**
Every factory receives three parameters: 1) the properties object, 2) a configuration that should be used to modify the behavior of the factory, and 3) an object with properties to call the factories defined at CustomError.factory. If a custom error inherits from another custom error then all factories in the inheritance chain are called, starting at the topmost parent. The factory function is called with the scope of the error instance.
```js
var CustomError = require('custom-error-instance');
var MyError = CustomError('MyError', function(properties, config, factory) {
factory.root(properties, config);
this.properties = properties;
});
var e = new MyError('Oops');
console.log(e.properties.message); // "Oops"
```

View file

@ -0,0 +1,151 @@
"use strict";
module.exports = CustomError;
CustomError.factory = require('./factories.js');
var Err = CustomError('CustomError');
Err.order = CustomError(Err, { message: 'Arguments out of order.', code: 'EOARG' });
/**
* Create a custom error
* @param {string} [name] The name to give the error. Defaults to the name of it's parent.
* @param {function} [parent] The Error or CustomError constructor to inherit from.
* @param {object} [properties] The default properties for the custom error.
* @param {function} [factory] A function to call to modify the custom error instance when it is instantiated.
* @returns {function} that should be used as a constructor.
*/
function CustomError(name, parent, properties, factory) {
var construct;
var isRoot;
// normalize arguments
parent = findArg(arguments, 1, Error, isParentArg, [isPropertiesArg, isFactoryArg]);
properties = findArg(arguments, 2, {}, isPropertiesArg, [isFactoryArg]);
factory = findArg(arguments, 3, noop, isFactoryArg, []);
name = findArg(arguments, 0, parent === Error ? 'Error' : parent.prototype.CustomError.name, isNameArg, [isParentArg, isPropertiesArg, isFactoryArg]);
// if this is the root and their is no factory then use the default root factory
isRoot = parent === Error;
if (isRoot && factory === noop) factory = CustomError.factory.root;
// build the constructor function
construct = function(message, configuration) {
var _this;
var ar;
var factories;
var i;
var item;
var props;
// force this function to be called with the new keyword
if (!(this instanceof construct)) return new construct(message, configuration);
// rename the constructor
delete this.constructor.name;
Object.defineProperty(this.constructor, 'name', {
enumerable: false,
configurable: true,
value: name,
writable: false
});
// make sure that the message is an object
if (typeof message === 'string') message = { message: message };
if (!message) message = {};
// build the properties object
ar = this.CustomError.chain.slice(0).reverse().map(function(value) { return value.properties });
ar.push(message);
ar.unshift({});
props = Object.assign.apply(Object, ar);
// build the factories caller (forcing scope to this)
_this = this;
factories = {};
Object.keys(CustomError.factory).forEach(function(key) {
factories[key] = function(props, config) {
CustomError.factory[key].call(_this, props, config, factories);
};
});
// call each factory in the chain, starting at the root
for (i = this.CustomError.chain.length - 1; i >= 0; i--) {
item = this.CustomError.chain[i];
if (item.factory !== noop) {
item.factory.call(this, props, configuration, factories);
}
}
};
// cause the function prototype to inherit from parent's prototype
construct.prototype = Object.create(parent.prototype);
construct.prototype.constructor = construct;
// update error name
construct.prototype.name = name;
// add details about the custom error to the prototype
construct.prototype.CustomError = {
chain: isRoot ? [] : parent.prototype.CustomError.chain.slice(0),
factory: factory,
name: name,
parent: parent,
properties: properties
};
construct.prototype.CustomError.chain.unshift(construct.prototype.CustomError);
// update the toString method on the prototype to accept a code
construct.prototype.toString = function() {
var result = this.CustomError.chain[this.CustomError.chain.length - 1].name;
if (this.code) result += ' ' + this.code;
if (this.message) result += ': ' + this.message;
return result;
};
return construct;
}
function findArg(args, index, defaultValue, filter, antiFilters) {
var anti = -1;
var found = -1;
var i;
var j;
var len = index < args.length ? index : args.length;
var val;
for (i = 0; i <= len; i++) {
val = args[i];
if (anti === -1) {
for (j = 0; j < antiFilters.length; j++) {
if (antiFilters[j](val)) anti = i;
}
}
if (found === -1 && filter(val)) {
found = i;
}
}
if (found !== -1 && anti !== -1 && anti < found) throw new Err.order();
return found !== -1 ?args[found] : defaultValue;
}
function isFactoryArg(value) {
return typeof value === 'function' && value !== Error && !value.prototype.CustomError;
}
function isNameArg(value) {
return typeof value === 'string';
}
function isParentArg(value) {
return typeof value === 'function' && (value === Error || value.prototype.CustomError);
}
function isPropertiesArg(value) {
return value && typeof value === 'object';
}
function noop() {}

View file

@ -0,0 +1,87 @@
"use strict";
exports.expectReceive = function(properties, configuration, factory) {
var message;
factory.root(properties, configuration, factory);
message = this.message;
if (properties.hasOwnProperty('expected')) message += ' Expected ' + properties.expected + '.';
if (properties.hasOwnProperty('received')) message += ' Received: ' + properties.received + '.';
this.message = message;
};
exports.root = function(properties, configuration, factories) {
var _this = this;
var code;
var config = { stackLength: Error.stackTraceLimit, rootOnly: true };
var messageStr = '';
var originalStackLength = Error.stackTraceLimit;
var stack;
function updateStack() {
stack[0] = _this.toString();
_this.stack = stack.join('\n');
}
// get configuration options
if (!configuration || typeof configuration !== 'object') configuration = {};
if (configuration.hasOwnProperty('stackLength') &&
typeof configuration.stackLength === 'number' &&
!isNaN(configuration.stackLength) &&
configuration.stackLength >= 0) config.stackLength = configuration.stackLength;
if (!configuration.hasOwnProperty('rootOnly')) config.rootOnly = configuration.rootOnly;
// check if this should only be run as root
if (!config.rootOnly || this.CustomError.parent === Error) {
// copy properties onto this object
Object.keys(properties).forEach(function(key) {
switch(key) {
case 'code':
code = properties.code || void 0;
break;
case 'message':
messageStr = properties.message || '';
break;
default:
_this[key] = properties[key];
}
});
// generate the stack trace
Error.stackTraceLimit = config.stackLength + 2;
stack = (new Error()).stack.split('\n');
stack.splice(0, 3);
stack.unshift('');
Error.stackTraceLimit = originalStackLength;
this.stack = stack.join('\n');
Object.defineProperty(this, 'code', {
configurable: true,
enumerable: true,
get: function() {
return code;
},
set: function(value) {
code = value;
updateStack();
}
});
Object.defineProperty(this, 'message', {
configurable: true,
enumerable: true,
get: function() {
return messageStr;
},
set: function(value) {
messageStr = value;
updateStack();
}
});
updateStack();
}
};

View file

@ -0,0 +1,46 @@
var CustomError = require('../index');
// define a custom error with a default message
var Parent = CustomError('ParentError', { message: 'Parent error' });
// define a custom error that inherits from the Parent custom error
var Child = CustomError('ChildError', Parent, { message: 'Child error' });
var e;
// create an error instance that uses defaults
e = Parent();
console.log(e.toString()); // "ParentError: Parent error"
console.log(e.message); // "Parent error"
console.log(e.name); // "ParentError"
console.log(e.constructor.name); // "ParentError"
console.log(e instanceof Parent); // true
console.log(e instanceof Error); // true
// create an error instance that overwrites the default message
e = Parent('Hello');
console.log(e.toString()); // "ParentError: Hello"
console.log(e.message); // "Hello"
console.log(e.name); // "ParentError"
console.log(e.constructor.name); // "ParentError"
console.log(e instanceof Parent); // true
console.log(e instanceof Error); // true
// create an error instance that overwrites the default message and defines a code
e = Parent({ message: 'Hello', code: 'XYZ' });
console.log(e.toString()); // "ParentError XYZ: Hello"
console.log(e.message); // "Hello"
console.log(e.name); // "ParentError"
console.log(e.constructor.name); // "ParentError"
console.log(e instanceof Parent); // true
console.log(e instanceof Error); // true
// create an error instance of the Child custom error
e = Child();
console.log(e.toString()); // "ParentError: Child error"
console.log(e.message); // "Child error"
console.log(e.name); // "ChildError"
console.log(e.constructor.name); // "ChildError"
console.log(e instanceof Child); // true
console.log(e instanceof Parent); // true
console.log(e instanceof Error); // true

View file

@ -0,0 +1,25 @@
"use strict";
var CustomError = require('../index');
var store = {};
var Err = CustomError('MapError');
Err.inuse = CustomError(Err, { message: 'The specified key is already in use.', code: 'INUSE' });
function add(key, value) {
if (Math.random() < .3) throw new Err('Random Error');
if (store.hasOwnProperty(key)) throw new Err.inuse();
store[key] = value;
}
try {
add('x', 1);
add('x', 2);
} catch (e) {
if (e instanceof Err.inuse) {
console.error(e.toString()); // "MapError INUSE: The specified key is already in use."
} else if (e instanceof Err) {
console.error('Unexpected ' + e); // "Unexpected MapError: Random Error"
} else {
throw e;
}
}

2
frontend/node_modules/custom-error-instance/index.js generated vendored Normal file
View file

@ -0,0 +1,2 @@
module.exports = require('./bin/error');

View file

@ -0,0 +1,27 @@
{
"name": "custom-error-instance",
"version": "2.1.1",
"description": "Create custom JavaScript errors that also match instanceof.",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/Gi60s/custom-error-instance.git"
},
"keywords": [
"error",
"custom",
"custom-error",
"instance",
"instanceof"
],
"author": "James Speirs",
"license": "ISC",
"bugs": {
"url": "https://github.com/Gi60s/custom-error-instance/issues"
},
"homepage": "https://github.com/Gi60s/custom-error-instance#readme",
"devDependencies": {
"chai": "^3.4.1"
},
"dependencies": {}
}

View file

@ -0,0 +1,198 @@
"use strict";
var expect = require('chai').expect;
var CustomError = require('../index');
describe('CustomError', function() {
describe('define', function() {
it('returns constructor function', function() {
expect(CustomError('MyError')).to.be.a('function');
});
describe('parameter tests', function() {
it('no parameters', function() {
var proto = CustomError().prototype.CustomError;
expect(proto.chain).to.be.an('Array');
expect(proto.factory).to.be.a('function');
expect(proto.name).to.be.equal('Error');
expect(proto.parent).to.be.equal(Error);
expect(proto.properties).to.be.deep.equal({});
});
describe('start name', function() {
it('name only', function() {
expect(CustomError('Foo').prototype.CustomError.name).to.be.equal('Foo');
});
it('name and parent', function() {
var P = CustomError();
var E = CustomError('Foo', P);
expect(E.prototype.CustomError.name).to.be.equal('Foo');
expect(E.prototype.CustomError.parent).to.be.equal(P);
});
it('name and properties', function() {
var E = CustomError('Foo', { foo: 'bar' });
expect(E.prototype.CustomError.name).to.be.equal('Foo');
expect(E.prototype.CustomError.properties).to.be.deep.equal({ foo: 'bar' });
});
it('name and factory', function() {
var fn = function() {};
var E = CustomError('Foo', fn);
expect(E.prototype.CustomError.name).to.be.equal('Foo');
expect(E.prototype.CustomError.factory).to.be.equal(fn);
});
});
describe('start parent', function() {
it('parent only', function() {
var E = CustomError();
expect(CustomError(E).prototype.CustomError.parent).to.be.equal(E);
});
it('parent and properties', function() {
var P = CustomError();
var E = CustomError(P, { foo: 'bar' });
expect(E.prototype.CustomError.parent).to.be.equal(P);
expect(E.prototype.CustomError.properties).to.be.deep.equal({ foo: 'bar' });
});
it('should fail properties then parent', function() {
try {
var P = CustomError();
var E = CustomError({ foo: 'bar' }, P);
throw new Error('Should have failed');
} catch (e) {
expect(e.name).to.be.equal('CustomError');
expect(e.code).to.be.equal('EOARG');
}
});
it('parent and factory', function() {
var fn = function() {};
var P = CustomError();
var E = CustomError(P, fn);
expect(E.prototype.CustomError.parent).to.be.equal(P);
expect(E.prototype.CustomError.factory).to.be.equal(fn);
});
});
describe('start properties', function() {
it('properties only', function() {
expect(CustomError({ foo: 'bar' }).prototype.CustomError.properties).to.be.deep.equal({ foo: 'bar' });
});
it('properties and factory', function() {
var fn = function() {};
var E = CustomError({ foo: 'bar' }, fn);
expect(E.prototype.CustomError.properties).to.be.deep.equal({ foo: 'bar' });
expect(E.prototype.CustomError.factory).to.be.equal(fn);
});
});
describe('start factory', function() {
it('factory only', function() {
var fn = function() {};
expect(CustomError(fn).prototype.CustomError.factory).to.be.equal(fn);
});
});
});
});
describe('inherit', function() {
it('inherits from Error', function() {
var E = CustomError();
expect(E()).to.be.instanceof(Error);
});
it('instance of self custom error constructor', function() {
var E = CustomError();
expect(E()).to.be.instanceof(E);
});
it('inherits from custom error', function() {
var P = CustomError();
var E = CustomError(P);
var e = E();
expect(e).to.be.instanceof(Error);
expect(e).to.be.instanceof(P);
expect(e).to.be.instanceof(E);
});
});
describe('name', function() {
it('instance has name provided', function() {
var e = CustomError('FooError')();
expect(e.name).to.be.equal('FooError');
});
it('instance has name inherited', function() {
var P = CustomError('FooError');
var e = CustomError(P)();
expect(e.name).to.be.equal('FooError');
});
it('instance has constructor name provided', function() {
var e = CustomError('FooError')();
expect(e.constructor.name).to.be.equal('FooError');
});
it('instance has constructor name inherited', function() {
var P = CustomError('FooError');
var e = CustomError(P)();
expect(e.constructor.name).to.be.equal('FooError');
});
});
describe('factory', function() {
it('default factory', function() {
var E = CustomError();
var e = E('Hello');
expect(e.message).to.be.equal('Hello');
});
it('custom factory', function() {
var fn = function(props, config) { this.message = JSON.stringify(props); };
var e = CustomError(fn)('Hello');
expect(e.message).to.be.equal('{"message":"Hello"}');
expect(e.stack).to.be.undefined;
});
it('custom factory calling root', function() {
var fn = function(props, config, factory) {
factory.root(props, config);
this.message += ', Bob';
};
var e = CustomError(fn)('Hello');
expect(e.message).to.be.equal('Hello, Bob');
expect(e.stack).to.not.be.undefined;
});
it('custom and inherited factory', function() {
var fn = function(props, config) { this.message += 'ABC'; };
var P = CustomError();
var e = CustomError(P, fn)('Hello');
expect(e.message).to.be.equal('HelloABC');
});
});
});