aboutsummaryrefslogtreecommitdiff
path: root/lib/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils.js')
-rw-r--r--lib/utils.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/utils.js b/lib/utils.js
index a0571d65..46adfd4c 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -78,13 +78,28 @@ function repeat_string(str, i) {
return d;
};
+function configure_error_stack(fn) {
+ Object.defineProperty(fn.prototype, "stack", {
+ get: function() {
+ var err = new Error(this.message);
+ err.name = this.name;
+ try {
+ throw err;
+ } catch(e) {
+ return e.stack;
+ }
+ }
+ });
+}
+
function DefaultsError(msg, defs) {
- Error.call(this, msg);
- this.msg = msg;
+ this.message = msg;
this.defs = defs;
};
DefaultsError.prototype = Object.create(Error.prototype);
DefaultsError.prototype.constructor = DefaultsError;
+DefaultsError.prototype.name = "DefaultsError";
+configure_error_stack(DefaultsError);
DefaultsError.croak = function(msg, defs) {
throw new DefaultsError(msg, defs);