mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-06 01:41:37 +08:00
Bug 703459: Handle undefined argument to Error constructor.
This commit is contained in:
@@ -57,9 +57,8 @@ static void Ep_toString(js_State *J)
|
|||||||
|
|
||||||
static int jsB_ErrorX(js_State *J, js_Object *prototype)
|
static int jsB_ErrorX(js_State *J, js_Object *prototype)
|
||||||
{
|
{
|
||||||
int top = js_gettop(J);
|
|
||||||
js_pushobject(J, jsV_newobject(J, JS_CERROR, prototype));
|
js_pushobject(J, jsV_newobject(J, JS_CERROR, prototype));
|
||||||
if (top > 1) {
|
if (js_isdefined(J, 1)) {
|
||||||
js_pushstring(J, js_tostring(J, 1));
|
js_pushstring(J, js_tostring(J, 1));
|
||||||
js_defproperty(J, -2, "message", JS_DONTENUM);
|
js_defproperty(J, -2, "message", JS_DONTENUM);
|
||||||
}
|
}
|
||||||
@@ -109,7 +108,6 @@ void jsB_initerror(js_State *J)
|
|||||||
js_pushobject(J, J->Error_prototype);
|
js_pushobject(J, J->Error_prototype);
|
||||||
{
|
{
|
||||||
jsB_props(J, "name", "Error");
|
jsB_props(J, "name", "Error");
|
||||||
jsB_props(J, "message", "an error has occurred");
|
|
||||||
jsB_propf(J, "Error.prototype.toString", Ep_toString, 0);
|
jsB_propf(J, "Error.prototype.toString", Ep_toString, 0);
|
||||||
}
|
}
|
||||||
js_newcconstructor(J, jsB_Error, jsB_Error, "Error", 1);
|
js_newcconstructor(J, jsB_Error, jsB_Error, "Error", 1);
|
||||||
|
|||||||
7
jsrepr.c
7
jsrepr.c
@@ -220,9 +220,10 @@ static void reprvalue(js_State *J, js_Buffer **sb)
|
|||||||
js_puts(J, sb, js_tostring(J, -1));
|
js_puts(J, sb, js_tostring(J, -1));
|
||||||
js_pop(J, 1);
|
js_pop(J, 1);
|
||||||
js_putc(J, sb, '(');
|
js_putc(J, sb, '(');
|
||||||
js_getproperty(J, -1, "message");
|
if (js_hasproperty(J, -1, "message")) {
|
||||||
reprstr(J, sb, js_tostring(J, -1));
|
reprvalue(J, sb);
|
||||||
js_pop(J, 1);
|
js_pop(J, 1);
|
||||||
|
}
|
||||||
js_puts(J, sb, "))");
|
js_puts(J, sb, "))");
|
||||||
break;
|
break;
|
||||||
case JS_CMATH:
|
case JS_CMATH:
|
||||||
|
|||||||
7
main.c
7
main.c
@@ -220,10 +220,13 @@ static const char *require_js =
|
|||||||
"require.cache = Object.create(null);\n"
|
"require.cache = Object.create(null);\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
static const char *stacktrace_js =
|
static const char *stacktrace_js =
|
||||||
"Error.prototype.toString = function() {\n"
|
"Error.prototype.toString = function() {\n"
|
||||||
"if (this.stackTrace) return this.name + ': ' + this.message + this.stackTrace;\n"
|
"var s = this.name;\n"
|
||||||
"return this.name + ': ' + this.message;\n"
|
"if ('message' in this) s += ': ' + this.message;\n"
|
||||||
|
"if ('stackTrace' in this) s += this.stackTrace;\n"
|
||||||
|
"return s;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user