printStackTrace in doassert in JS land

This commit is contained in:
Mathias Stearn
2010-08-16 11:33:41 -04:00
parent 16ce34f241
commit ab4c0fe09e
2 changed files with 18 additions and 0 deletions

View File

@@ -21,11 +21,20 @@ const StringData _jscode_raw_utils =
"return false;\n"
"}\n"
"\n"
"printStackTrace = function(){\n"
"try{\n"
"throw new Error(\"Printing Stack Trace (lines are 0-based in spidermonkey)\");\n"
"} catch (e) {\n"
"print(e.stack);\n"
"}\n"
"}\n"
"\n"
"doassert = function (msg) {\n"
"if (msg.indexOf(\"assert\") == 0)\n"
"print(msg);\n"
"else\n"
"print(\"assert: \" + msg);\n"
"printStackTrace();\n"
"throw msg;\n"
"}\n"
"\n"