Module error

Module error 

Source
Expand description

Runtime Error Handling

Provides thread-local error state for FFI functions to report errors without panicking across the FFI boundary.

§Usage

FFI functions can set an error instead of panicking:

if divisor == 0 {
    set_runtime_error("divide: division by zero");
    return stack; // Return unchanged stack
}

Callers can check for errors:

if patch_seq_has_error() {
    let error = patch_seq_take_error();
    // Handle error...
}

Functions§

clear_runtime_error
Clear any pending runtime error
format_panic_payload
Format a panic payload into an error message
has_runtime_error
Check if there’s a pending runtime error
patch_seq_clear_error
Clear any pending error (FFI-safe)
patch_seq_get_error
Get the last error message as a C string pointer (FFI-safe)
patch_seq_has_error
Check if there’s a pending runtime error (FFI-safe)
patch_seq_take_error
Take (and clear) the last error, returning it as a C string (FFI-safe)
set_runtime_error
Set the last runtime error message
take_runtime_error
Take (and clear) the last runtime error message