'use strict'; function assign(obj, props) { for (const key in props) { Object.defineProperty(obj, key, { value: props[key], enumerable: true, configurable: true, }); } return obj; } function createError(err, code, props) { if (!err || typeof err === 'string') { throw new TypeError('Please pass an Error to err-code'); } if (!props) { props = {}; } if (typeof code === 'object') { props = code; code = undefined; } if (code != null) { props.code = code; } try { return assign(err, props); } catch (_) { props.message = err.message; props.stack = err.stack; const ErrClass = function () {}; ErrClass.prototype = Object.create(Object.getPrototypeOf(err)); return assign(new ErrClass(), props); } } module.exports = createError;
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
test | Folder | 0755 |
|
|
.editorconfig | File | 179 B | 0644 |
|
.eslintrc.json | File | 127 B | 0644 |
|
.travis.yml | File | 43 B | 0644 |
|
README.md | File | 2.42 KB | 0644 |
|
bower.json | File | 589 B | 0644 |
|
index.js | File | 933 B | 0644 |
|
index.umd.js | File | 1.78 KB | 0644 |
|
package.json | File | 844 B | 0644 |
|