fix disrupts

This commit is contained in:
2026-02-09 11:28:10 -06:00
parent 45556c344d
commit 3934cdb683
4 changed files with 25 additions and 5 deletions

View File

@@ -635,7 +635,12 @@ int cell_init(int argc, char **argv)
if (JS_IsException(result)) {
JSValue exc = JS_GetException(ctx);
const char *str = JS_ToCString(ctx, exc);
const char *str = NULL;
if (JS_IsObject(exc)) {
JSValue msg = JS_GetPropertyStr(ctx, exc, "message");
str = JS_ToCString(ctx, msg);
}
if (!str) str = JS_ToCString(ctx, exc);
if (str) { printf("Error: %s\n", str); JS_FreeCString(ctx, str); }
cJSON *stack = JS_GetStack(ctx);
if (stack) {
@@ -775,7 +780,12 @@ int cell_init(int argc, char **argv)
int exit_code = 0;
if (JS_IsException(result)) {
JSValue exc = JS_GetException(ctx);
const char *err_str = JS_ToCString(ctx, exc);
const char *err_str = NULL;
if (JS_IsObject(exc)) {
JSValue msg = JS_GetPropertyStr(ctx, exc, "message");
err_str = JS_ToCString(ctx, msg);
}
if (!err_str) err_str = JS_ToCString(ctx, exc);
if (err_str) {
printf("Error: %s\n", err_str);
JS_FreeCString(ctx, err_str);

View File

@@ -2919,7 +2919,12 @@ JSValue JS_CallRegisterVM(JSContext *ctx, JSCodeRegister *code,
break;
}
if (JS_IsNull(frame->caller)) {
result = JS_Throw(ctx, JS_NewString(ctx, "unhandled disruption"));
/* Re-throw the original exception so the caller sees the real message */
JSValue exc = JS_GetException(ctx);
if (JS_IsNull(exc))
result = JS_ThrowInternalError(ctx, "unhandled disruption");
else
result = JS_Throw(ctx, exc);
frame = (JSFrameRegister *)JS_VALUE_GET_PTR(frame_ref.val);
goto done;
}

View File

@@ -3406,7 +3406,12 @@ JSValue mcode_exec(JSContext *ctx, JSMCode *code, JSValue this_obj,
break;
}
if (JS_IsNull(frame->caller)) {
result = JS_Throw(ctx, JS_NewString(ctx, "unhandled disruption"));
/* Re-throw the original exception so the caller sees the real message */
JSValue exc = JS_GetException(ctx);
if (JS_IsNull(exc))
result = JS_ThrowInternalError(ctx, "unhandled disruption");
else
result = JS_Throw(ctx, exc);
frame = (JSFrameRegister *)JS_VALUE_GET_PTR(frame_ref.val);
goto done;
}

View File

@@ -11799,7 +11799,7 @@ static void JS_AddIntrinsicBaseObjects (JSContext *ctx) {
/* Core functions - using GC-safe helper */
js_set_global_cfunc(ctx, "eval", js_cell_eval, 2);
js_set_global_cfunc(ctx, "mach_eval", js_mach_eval, 2);
js_set_global_cfunc(ctx, "mach_eval", js_mach_eval, 3);
js_set_global_cfunc(ctx, "stone", js_cell_stone, 1);
js_set_global_cfunc(ctx, "length", js_cell_length, 1);
js_set_global_cfunc(ctx, "call", js_cell_call, 3);