From 24cf18651aaecc419646ffeafb6ed2a114d4a637 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Mon, 3 Jan 2022 02:25:11 +0000 Subject: [PATCH] Fixed some error reporting. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3733 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- core/core.js | 6 +++++- src/serialize.c | 4 ---- src/task.c | 17 +++++++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/core/core.js b/core/core.js index 272b25e5..af7ea016 100644 --- a/core/core.js +++ b/core/core.js @@ -249,7 +249,11 @@ async function getProcessBlob(blobId, key, options) { } await process.task.execute({name: blobId, source: appSource}); } catch (error) { - printError({print: print}, error); + if (process.app) { + process.app.send({action: 'error', error: error}); + } else { + printError({print: print}, error); + } rejectReady(); } } diff --git a/src/serialize.c b/src/serialize.c index 671a2aa9..13e3a572 100644 --- a/src/serialize.c +++ b/src/serialize.c @@ -243,10 +243,6 @@ static bool _serialize_storeInternal(tf_task_t* task, tf_taskstub_t* to, buffer_ { JS_SetPropertyStr(context, error, "message", message); } - else - { - JS_FreeValue(context, message); - } if (JS_IsError(context, exception)) { JSValue stack = JS_GetPropertyStr(context, exception, "stack"); diff --git a/src/task.c b/src/task.c index 1407b8ae..1492b797 100644 --- a/src/task.c +++ b/src/task.c @@ -765,10 +765,17 @@ void tf_task_on_receive_packet(int packetType, const char* begin, size_t length, JSValue utf8 = tf_util_utf8_decode(to->_context, source); const char* source_str = JS_ToCString(to->_context, utf8); JS_FreeValue(to->_context, utf8); - _tf_task_executeSource(to, source_str, name); + JSValue result = _tf_task_executeSource(to, source_str, name); + if (JS_IsException(result)) + { + _tf_task_sendPromiseReject(to, from, promise, JS_GetException(to->_context)); + } + else + { + _tf_task_sendPromiseResolve(to, from, promise, result); + } JS_FreeCString(to->_context, source_str); JS_FreeCString(to->_context, name); - _tf_task_sendPromiseResolve(to, from, promise, JS_UNDEFINED); } break; case kKill: @@ -930,12 +937,14 @@ static JSValue _tf_task_executeSource(tf_task_t* task, const char* source, const { tf_trace_begin(task->_trace, "_tf_task_executeSource"); JSValue result = JS_Eval(task->_context, source, strlen(source), name, 0); - tf_util_report_error(task->_context, result); if (!*task->_scriptName) { snprintf(task->_scriptName, sizeof(task->_scriptName), "%s", name); } - tf_task_run_jobs(task); + if (!JS_IsException(result)) + { + tf_task_run_jobs(task); + } tf_trace_end(task->_trace); return result; }