Skip to main content

Module error

Module error 

Source
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 CatchUnwind guard (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
}

Functions§

r_stop
Raise an R error via Rf_error (longjmp). Do not call from user code — use panic!() instead, which is caught by the framework.
r_warning
Raise an R warning with the given message.