ref: c1bd06728a4d37eab587ab8e2d8516e4ae24ce5e
parent: 9321f8fec69afe99e15c1e06ad588d319fa7a1e7
author: Tor Andersson <tor.andersson@gmail.com>
date: Wed Apr 19 19:49:01 EDT 2017
Don't truncate error messages.
--- a/jsdump.c
+++ b/jsdump.c
@@ -826,7 +826,7 @@
case JS_CBOOLEAN: printf("[Boolean %d]", v.u.object->u.boolean); break;
case JS_CNUMBER: printf("[Number %g]", v.u.object->u.number); break;
case JS_CSTRING: printf("[String'%s']", v.u.object->u.s.string); break;
- case JS_CERROR: printf("[Error %s]", v.u.object->u.s.string); break;
+ case JS_CERROR: printf("[Error]"); break;
case JS_CITERATOR: printf("[Iterator %p]", (void*)v.u.object); break;
case JS_CUSERDATA:
printf("[Userdata %s %p]", v.u.object->u.user.tag, v.u.object->u.user.data);
--- a/jserror.c
+++ b/jserror.c
@@ -31,7 +31,6 @@
static void Ep_toString(js_State *J)
{
- char buf[256];
const char *name = "Error";
const char *message = "";
@@ -43,8 +42,17 @@
if (js_hasproperty(J, 0, "message"))
message = js_tostring(J, -1);
- snprintf(buf, sizeof buf, "%s: %s", name, message);
- js_pushstring(J, buf);
+ if (name[0] == 0)
+ js_pushstring(J, message);
+ else if (message[0] == 0)
+ js_pushstring(J, name);
+ else {
+ js_pushstring(J, name);
+ js_pushstring(J, ": ");
+ js_concat(J);
+ js_pushstring(J, message);
+ js_concat(J);
+ }
if (js_hasproperty(J, 0, "stackTrace"))
js_concat(J);