set_error_handler now also set the uncaught exception level
HL_PRIM hl_trap_ctx *hl_current_trap = NULL;
HL_PRIM vdynamic *hl_current_exc = NULL;
HL_PRIM vdynamic **hl_debug_exc = NULL;
-
+static hl_trap_ctx *hl_trap_root = NULL;
static void *stack_trace[0x1000];
static int stack_count = 0;
static bool exc_rethrow = false;
@@ -77,13 +77,13 @@ HL_PRIM void hl_setup_exception( void *resolve_symbol, void *capture_stack ) {
}
HL_PRIM void hl_set_error_handler( vclosure *d ) {
+ hl_trap_root = hl_current_trap;
if( d == hl_error_handler )
return;
hl_error_handler = d;
+ hl_remove_root(&hl_error_handler);
if( d )
hl_add_root(&hl_error_handler);
- else
- hl_remove_root(&hl_error_handler);
}
HL_PRIM void hl_throw( vdynamic *v ) {
@@ -94,7 +94,7 @@ HL_PRIM void hl_throw( vdynamic *v ) {
stack_count = capture_stack_func(stack_trace, 0x1000);
hl_current_exc = v;
hl_current_trap = t->prev;
- if( hl_current_trap == NULL ) {
+ if( hl_current_trap == hl_trap_root || hl_current_trap == NULL ) {
hl_debug_exc = &v;
hl_debug_break();
hl_debug_exc = NULL;
