diff --git a/src/errors.js b/src/errors.js index b6597e8..279ff81 100644 --- a/src/errors.js +++ b/src/errors.js @@ -1,6 +1,7 @@ -export function RuntimeError(message, input) { +export function RuntimeError(message, input, cause) { this.message = message + ""; this.input = input; + this.cause = cause; } RuntimeError.prototype = Object.create(Error.prototype); diff --git a/src/variable.js b/src/variable.js index 00132d8..671bce7 100644 --- a/src/variable.js +++ b/src/variable.js @@ -58,7 +58,7 @@ function variable_undefined() { function variable_rejector(variable) { return function(error) { if (error === variable_undefined) throw new RuntimeError(variable._name + " is not defined", variable._name); - if (error instanceof Error && error.message) throw new RuntimeError(error.message, variable._name); + if (error instanceof Error && error.message) throw new RuntimeError(error.message, variable._name, error); throw new RuntimeError(variable._name + " could not be resolved", variable._name); }; }