mirror of
https://github.com/ccxvii/mujs.git
synced 2025-12-06 18:22:47 +08:00
Bug 708625: Use more common "stack" property for error stack trace.
This commit is contained in:
@@ -61,7 +61,7 @@ static int jsB_ErrorX(js_State *J, js_Object *prototype)
|
||||
js_defproperty(J, -2, "message", JS_DONTENUM);
|
||||
}
|
||||
if (jsB_stacktrace(J, 1))
|
||||
js_defproperty(J, -2, "stackTrace", JS_DONTENUM);
|
||||
js_defproperty(J, -2, "stack", JS_DONTENUM);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ static void js_newerrorx(js_State *J, const char *message, js_Object *prototype)
|
||||
js_pushstring(J, message);
|
||||
js_setproperty(J, -2, "message");
|
||||
if (jsB_stacktrace(J, 0))
|
||||
js_setproperty(J, -2, "stackTrace");
|
||||
js_setproperty(J, -2, "stack");
|
||||
}
|
||||
|
||||
#define DERROR(name, Name) \
|
||||
|
||||
2
main.c
2
main.c
@@ -225,7 +225,7 @@ static const char *stacktrace_js =
|
||||
"Error.prototype.toString = function() {\n"
|
||||
"var s = this.name;\n"
|
||||
"if ('message' in this) s += ': ' + this.message;\n"
|
||||
"if ('stackTrace' in this) s += this.stackTrace;\n"
|
||||
"if ('stack' in this) s += this.stack;\n"
|
||||
"return s;\n"
|
||||
"};\n"
|
||||
;
|
||||
|
||||
@@ -127,16 +127,16 @@
|
||||
var msg = !neg_str ? err : "[Mismatch @negative " + neg_str + "]" + "\n " + err;
|
||||
|
||||
info += (result.runtime ? "[run] " : "[load] ") + msg;
|
||||
if (err && err.stackTrace && (result.runtime || full_mode)) {
|
||||
if (err && err.stack && (result.runtime || full_mode)) {
|
||||
if (full_mode) {
|
||||
info += err.stackTrace;
|
||||
info += err.stack;
|
||||
} else {
|
||||
// trim the internal loader from the trace
|
||||
var internal = err.stackTrace.indexOf("\n" + load("mujs_blahblah()").err.stackTrace.trim().split("\n")[1]);
|
||||
var internal = err.stack.indexOf("\n" + load("mujs_blahblah()").err.stack.trim().split("\n")[1]);
|
||||
if (internal >= 0)
|
||||
info += err.stackTrace.substring(0, internal);
|
||||
info += err.stack.substring(0, internal);
|
||||
else
|
||||
info += err.stackTrace;
|
||||
info += err.stack;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user