Validate exit codes more thoroughly. C'mon, Cory.

This commit is contained in:
2024-04-02 20:32:47 -04:00
parent 9f3171e3f1
commit e50144bd34
3 changed files with 22 additions and 5 deletions

View File

@ -113,8 +113,8 @@ typedef struct _tf_task_t
bool _trusted;
bool _one_proc;
bool _killed;
int32_t _exitCode;
char _scriptName[256];
int _global_exception_count;
JSRuntime* _runtime;
JSContext* _context;
@ -421,11 +421,11 @@ int tf_task_execute(tf_task_t* task, const char* fileName)
if (source)
{
JSValue result = JS_Eval(task->_context, source, strlen(source), fileName, JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_ASYNC);
if (tf_util_report_error(task->_context, result))
if (tf_util_report_error(task->_context, result) || task->_global_exception_count)
{
tf_printf("Reported an error.\n");
}
if (!JS_IsError(task->_context, result) && !JS_IsException(result))
else
{
executed = true;
}
@ -1457,6 +1457,8 @@ static void _tf_task_promise_rejection_tracker(JSContext* context, JSValueConst
if (!is_handled)
{
tf_util_report_error(context, reason);
tf_task_t* task = tf_task_get(context);
task->_global_exception_count++;
}
}