Compare commits

..

No commits in common. '780b5946af4ddb78707c3e32cad403f5984d7192' and '93be20f9c12db9bdc24a42e438f245ad382ea1be' have entirely different histories.

@ -3,6 +3,3 @@ benefits of eTry
- you can wrap calls in it, as it's an expression, not a statement like try/catch
note that it does not work with async/await, where you're stuck with the manual approach
TODO:
- Add a (maybe)fromGraphQL utility for converting GraphQL's wrapper errors (with `originalError`) into a standard error chain

@ -1,6 +1,6 @@
{
"name": "error-chain",
"version": "0.1.3",
"version": "0.1.2",
"main": "index.js",
"repository": "git@git.cryto.net:joepie91/node-error-chain.git",
"author": "Sven Slootweg <admin@cryto.net>",

@ -11,13 +11,6 @@ const forbidSpecialProperties = require("./validators/forbid-special-properties"
const isErrorConstructor = require("./validators/is-error-constructor");
const isContextSchema = require("./validators/is-context-schema");
function safeAssign(a, ... rest) {
let previousPrototype = a.__proto__;
Object.assign(a, ... rest);
a.__proto__ = previousPrototype;
return a;
}
module.exports = function createCustomErrorType(_name, _options) {
let [ name, options ] = validateArguments(arguments, {
name: [ required, isString ],
@ -55,7 +48,7 @@ module.exports = function createCustomErrorType(_name, _options) {
}
ErrorConstructor._assignDefaultProperties(this);
safeAssign(this, context);
Object.assign(this, context);
};
ErrorConstructor._assignDefaultProperties = function (errorObject) {
@ -65,7 +58,7 @@ module.exports = function createCustomErrorType(_name, _options) {
options.inheritsFrom._assignDefaultProperties(errorObject);
}
safeAssign(errorObject, options.context);
Object.assign(errorObject, options.context);
};
ErrorConstructor.prototype = Object.create(options.inheritsFrom.prototype);

@ -7,5 +7,6 @@ module.exports = [
"message",
"stack",
"cause",
"__proto__",
"constructor"
];

Loading…
Cancel
Save