Compare commits

...

2 Commits

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

@ -1,6 +1,7 @@
"use strict"; "use strict";
module.exports = function chain(originalError, ErrorType, ... args) { module.exports = function chain(originalError, ErrorType, ... args) {
// FIXME: Validate that the ErrorType is actually an error-chain-generated type (via error._errorChainError)
let error = new ErrorType(... args); let error = new ErrorType(... args);
error.cause = originalError; error.cause = originalError;
return error; return error;

@ -58,7 +58,7 @@ module.exports = function createCustomErrorType(_name, _options) {
options.inheritsFrom._assignDefaultProperties(errorObject); options.inheritsFrom._assignDefaultProperties(errorObject);
} }
Object.assign(this, options.context); Object.assign(errorObject, options.context);
}; };
ErrorConstructor.prototype = Object.create(options.inheritsFrom.prototype); ErrorConstructor.prototype = Object.create(options.inheritsFrom.prototype);

Loading…
Cancel
Save