improve usability (#5753)
This commit is contained in:
14
lib/utils.js
14
lib/utils.js
@@ -65,8 +65,12 @@ function configure_error_stack(ex, cause) {
|
||||
var msg = "" + cause.message;
|
||||
cause = null;
|
||||
var index = stack.indexOf(msg);
|
||||
if (index >= 0) index += msg.length;
|
||||
index = stack.indexOf("\n", index) + 1;
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
} else {
|
||||
index += msg.length;
|
||||
index = stack.indexOf("\n", index) + 1;
|
||||
}
|
||||
stack = stack.slice(0, index) + stack.slice(stack.indexOf("\n", index) + 1);
|
||||
}
|
||||
return stack;
|
||||
@@ -77,7 +81,11 @@ function configure_error_stack(ex, cause) {
|
||||
function DefaultsError(msg, defs) {
|
||||
this.message = msg;
|
||||
this.defs = defs;
|
||||
configure_error_stack(this, new Error(msg));
|
||||
try {
|
||||
throw new Error(msg);
|
||||
} catch (cause) {
|
||||
configure_error_stack(this, cause);
|
||||
}
|
||||
}
|
||||
DefaultsError.prototype = Object.create(Error.prototype);
|
||||
DefaultsError.prototype.constructor = DefaultsError;
|
||||
|
||||
Reference in New Issue
Block a user