fix disrupts
This commit is contained in:
@@ -635,7 +635,12 @@ int cell_init(int argc, char **argv)
|
|||||||
|
|
||||||
if (JS_IsException(result)) {
|
if (JS_IsException(result)) {
|
||||||
JSValue exc = JS_GetException(ctx);
|
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); }
|
if (str) { printf("Error: %s\n", str); JS_FreeCString(ctx, str); }
|
||||||
cJSON *stack = JS_GetStack(ctx);
|
cJSON *stack = JS_GetStack(ctx);
|
||||||
if (stack) {
|
if (stack) {
|
||||||
@@ -775,7 +780,12 @@ int cell_init(int argc, char **argv)
|
|||||||
int exit_code = 0;
|
int exit_code = 0;
|
||||||
if (JS_IsException(result)) {
|
if (JS_IsException(result)) {
|
||||||
JSValue exc = JS_GetException(ctx);
|
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) {
|
if (err_str) {
|
||||||
printf("Error: %s\n", err_str);
|
printf("Error: %s\n", err_str);
|
||||||
JS_FreeCString(ctx, err_str);
|
JS_FreeCString(ctx, err_str);
|
||||||
|
|||||||
@@ -2919,7 +2919,12 @@ JSValue JS_CallRegisterVM(JSContext *ctx, JSCodeRegister *code,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (JS_IsNull(frame->caller)) {
|
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);
|
frame = (JSFrameRegister *)JS_VALUE_GET_PTR(frame_ref.val);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3406,7 +3406,12 @@ JSValue mcode_exec(JSContext *ctx, JSMCode *code, JSValue this_obj,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (JS_IsNull(frame->caller)) {
|
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);
|
frame = (JSFrameRegister *)JS_VALUE_GET_PTR(frame_ref.val);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11799,7 +11799,7 @@ static void JS_AddIntrinsicBaseObjects (JSContext *ctx) {
|
|||||||
|
|
||||||
/* Core functions - using GC-safe helper */
|
/* Core functions - using GC-safe helper */
|
||||||
js_set_global_cfunc(ctx, "eval", js_cell_eval, 2);
|
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, "stone", js_cell_stone, 1);
|
||||||
js_set_global_cfunc(ctx, "length", js_cell_length, 1);
|
js_set_global_cfunc(ctx, "length", js_cell_length, 1);
|
||||||
js_set_global_cfunc(ctx, "call", js_cell_call, 3);
|
js_set_global_cfunc(ctx, "call", js_cell_call, 3);
|
||||||
|
|||||||
Reference in New Issue
Block a user