From 3e8ce96c08f20092a0e968fa340a7aecbde82102 Mon Sep 17 00:00:00 2001 From: John Sebastian Peterson Date: Mon, 9 Sep 2024 13:00:36 +0300 Subject: [PATCH] print JavaScript errors etc for -test --- src/ecmascript/mujs.c | 4 ++-- src/ecmascript/quickjs.c | 7 +++---- src/ecmascript/quickjs/console.c | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ecmascript/mujs.c b/src/ecmascript/mujs.c index 20638d11c..7deb7641e 100644 --- a/src/ecmascript/mujs.c +++ b/src/ecmascript/mujs.c @@ -179,7 +179,7 @@ mujs_get_interpreter(struct ecmascript_interpreter *interpreter) interpreter->backend_data = ctx; JS_SetContextOpaque(ctx, interpreter); -// JS::SetWarningReporter(ctx, error_reporter); + JS::SetWarningReporter(ctx, error_reporter); JS_SetInterruptHandler(rt, js_heartbeat_callback, interpreter); // JS::RealmOptions options; @@ -267,7 +267,7 @@ mujs_eval(struct ecmascript_interpreter *interpreter, struct string *code, struct string *ret) { assert(interpreter); - + LOG_JS("%.100s...", code->source); js_State *J = (js_State *)interpreter->backend_data; interpreter->ret = ret; js_dostring(J, code->source); diff --git a/src/ecmascript/quickjs.c b/src/ecmascript/quickjs.c index bf6ccbe87..761225784 100644 --- a/src/ecmascript/quickjs.c +++ b/src/ecmascript/quickjs.c @@ -371,12 +371,10 @@ error_reporter(struct ecmascript_interpreter *interpreter, JSContext *ctx) set_led_value(ses->status.ecmascript_led, 'J'); #endif - if (!get_opt_bool("ecmascript.error_reporting", ses)) { - return; - } - if (init_string(&f)) { js_dump_error(ctx, &f); + LOG_JS("%s", f); + if (!get_opt_bool("ecmascript.error_reporting", ses)) return; if (!init_string(&msg)) { done_string(&f); @@ -401,6 +399,7 @@ quickjs_eval(struct ecmascript_interpreter *interpreter, // if (!js_module_init_ok) { // return; // } + LOG_JS("%.100s...", code->source); ctx = (JSContext *)interpreter->backend_data; interpreter->heartbeat = add_heartbeat(interpreter); interpreter->ret = ret; diff --git a/src/ecmascript/quickjs/console.c b/src/ecmascript/quickjs/console.c index e8990842a..36173984f 100644 --- a/src/ecmascript/quickjs/console.c +++ b/src/ecmascript/quickjs/console.c @@ -84,6 +84,7 @@ js_console_log_common(JSContext *ctx, JSValueConst this_val, int argc, JSValueCo if (!str) { return JS_EXCEPTION; } + LOG_JS("%s",str); FILE *f = fopen(log_filename, "a"); if (f)