summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-04-24 15:11:48 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-05-02 11:16:33 +0200
commiteffc6a80922f9d0ed976e98f36e57073fd1f77cc (patch)
tree267752387989d3d9d83999c1c582dc0fe5217cdc
parent4ad2a93470e859159fe8507fb6c3e2ef7995aa9b (diff)
downloadmupdf-effc6a80922f9d0ed976e98f36e57073fd1f77cc.tar.xz
Improve error handling in murun shell and update MuJS submodule.
-rw-r--r--source/tools/murun.c14
m---------thirdparty/mujs0
2 files changed, 11 insertions, 3 deletions
diff --git a/source/tools/murun.c b/source/tools/murun.c
index d9b5412e..6b2df126 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -38,18 +38,18 @@ static void *alloc(void *actx, void *ptr, int n)
static int eval_print(js_State *J, const char *source)
{
if (js_ploadstring(J, "[string]", source)) {
- fprintf(stderr, "%s\n", js_tostring(J, -1));
+ fprintf(stderr, "%s\n", js_trystring(J, -1, "Error"));
js_pop(J, 1);
return 1;
}
js_pushglobal(J);
if (js_pcall(J, 0)) {
- fprintf(stderr, "%s\n", js_tostring(J, -1));
+ fprintf(stderr, "%s\n", js_trystring(J, -1, "Error"));
js_pop(J, 1);
return 1;
}
if (js_isdefined(J, -1))
- printf("%s\n", js_tostring(J, -1));
+ printf("%s\n", js_trystring(J, -1, "can't convert to string"));
js_pop(J, 1);
return 0;
}
@@ -186,6 +186,13 @@ static const char *require_js =
"require.cache = Object.create(null);\n"
;
+static const char *stacktrace_js =
+ "Error.prototype.toString = function() {\n"
+ "if (this.stackTrace) return this.name + ': ' + this.message + this.stackTrace;\n"
+ "return this.name + ': ' + this.message;\n"
+ "};\n"
+;
+
/* destructors */
static void ffi_gc_fz_buffer(js_State *J, void *buf)
@@ -4454,6 +4461,7 @@ int murun_main(int argc, char **argv)
js_setglobal(J, "quit");
js_dostring(J, require_js);
+ js_dostring(J, stacktrace_js);
/* mupdf module */
diff --git a/thirdparty/mujs b/thirdparty/mujs
-Subproject 25821e6d74fab5fcc200fe5e818362e03e11442
+Subproject b46ee8d829027bb4eb54a49498205dda98857b2