summaryrefslogtreecommitdiff
path: root/src/scripts.c
diff options
context:
space:
mode:
authorportix <none@none>2013-01-18 17:30:02 +0100
committerportix <none@none>2013-01-18 17:30:02 +0100
commit06dcb414ec58dcbb02252da321f3f9d30df2d075 (patch)
treeeea1bdfddbbd5d9df7bda98637c1125d6c338f0f /src/scripts.c
parent002f488a9efe4d7314d8e4a1bce3c36c96d732df (diff)
downloaddwb-06dcb414ec58dcbb02252da321f3f9d30df2d075.zip
Print inject-errors to stderr
Diffstat (limited to 'src/scripts.c')
-rw-r--r--src/scripts.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/scripts.c b/src/scripts.c
index ed2b5e70..f3989656 100644
--- a/src/scripts.c
+++ b/src/scripts.c
@@ -193,13 +193,21 @@ inject(JSContextRef ctx, JSContextRef wctx, JSObjectRef function, JSObjectRef th
JSObjectRef func = JSObjectMakeFunction(wctx, NULL, 0, NULL, script, NULL, 0, NULL);
if (func != NULL && JSObjectIsFunction(ctx, func))
{
- JSValueRef wret = JSObjectCallAsFunction(wctx, func, NULL, count, count == 1 ? args : NULL, NULL) ;
- // This could be replaced with js_context_change
- char *retx = js_value_to_json(wctx, wret, -1, NULL);
- if (retx)
+ JSValueRef exc = NULL;
+ JSValueRef wret = JSObjectCallAsFunction(wctx, func, NULL, count, count == 1 ? args : NULL, &exc) ;
+ if (exc != NULL)
{
- ret = js_char_to_value(ctx, retx);
- g_free(retx);
+ fputs("DWB SCRIPT EXCEPTION: An error occured injecting a script.\n", stderr);
+ js_print_exception(wctx, exc);
+ }
+ else {
+ // This could be replaced with js_context_change
+ char *retx = js_value_to_json(wctx, wret, -1, NULL);
+ if (retx)
+ {
+ ret = js_char_to_value(ctx, retx);
+ g_free(retx);
+ }
}
}
}