Fixed some error reporting.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3733 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-01-03 02:25:11 +00:00
parent 3eabe72299
commit 24cf18651a
3 changed files with 18 additions and 9 deletions

View File

@ -249,7 +249,11 @@ async function getProcessBlob(blobId, key, options) {
} }
await process.task.execute({name: blobId, source: appSource}); await process.task.execute({name: blobId, source: appSource});
} catch (error) { } catch (error) {
if (process.app) {
process.app.send({action: 'error', error: error});
} else {
printError({print: print}, error); printError({print: print}, error);
}
rejectReady(); rejectReady();
} }
} }

View File

@ -243,10 +243,6 @@ static bool _serialize_storeInternal(tf_task_t* task, tf_taskstub_t* to, buffer_
{ {
JS_SetPropertyStr(context, error, "message", message); JS_SetPropertyStr(context, error, "message", message);
} }
else
{
JS_FreeValue(context, message);
}
if (JS_IsError(context, exception)) if (JS_IsError(context, exception))
{ {
JSValue stack = JS_GetPropertyStr(context, exception, "stack"); JSValue stack = JS_GetPropertyStr(context, exception, "stack");

View File

@ -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); JSValue utf8 = tf_util_utf8_decode(to->_context, source);
const char* source_str = JS_ToCString(to->_context, utf8); const char* source_str = JS_ToCString(to->_context, utf8);
JS_FreeValue(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, source_str);
JS_FreeCString(to->_context, name); JS_FreeCString(to->_context, name);
_tf_task_sendPromiseResolve(to, from, promise, JS_UNDEFINED);
} }
break; break;
case kKill: 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"); tf_trace_begin(task->_trace, "_tf_task_executeSource");
JSValue result = JS_Eval(task->_context, source, strlen(source), name, 0); JSValue result = JS_Eval(task->_context, source, strlen(source), name, 0);
tf_util_report_error(task->_context, result);
if (!*task->_scriptName) if (!*task->_scriptName)
{ {
snprintf(task->_scriptName, sizeof(task->_scriptName), "%s", name); snprintf(task->_scriptName, sizeof(task->_scriptName), "%s", name);
} }
if (!JS_IsException(result))
{
tf_task_run_jobs(task); tf_task_run_jobs(task);
}
tf_trace_end(task->_trace); tf_trace_end(task->_trace);
return result; return result;
} }