Expand description
Error handling helpers for R API calls.
In #[miniextendr] functions, use panic!() instead of r_stop.
Panics are caught by catch_unwind and propagated cleanly as R errors.
r_stop calls Rf_error (longjmp). It is used internally by:
- The proc-macro generated argument validation / return type unwrapping
- The
CatchUnwindguard (after catch_unwind has caught a panic) - Trait ABI shims
These are all inside R_UnwindProtect or after catch_unwind, where
Rf_error longjmp is safe. User code should never call r_stop directly.
§Example
ⓘ
use miniextendr_api::miniextendr;
#[miniextendr]
fn validate_input(x: i32) -> i32 {
assert!(x >= 0, "x must be non-negative, got {x}");
x * 2
}