Skip to main content

Module error_value

Module error_value 

Source
Expand description

Tagged error value transport for #[miniextendr(error_in_r)] mode.

When error_in_r is enabled, Rust-origin failures (panics, Result::Err, Option::None) are converted to a tagged SEXP value instead of raising an R error immediately. The generated R wrapper inspects this tagged value and escalates it to a proper R error condition past the Rust boundary.

This ensures Rust destructors run cleanly before R sees the error.

§Error value structure

The tagged SEXP is a named list with:

  • error: error message (character scalar)
  • kind: error kind string ("panic", "result_err", "none_err")
  • call: the R call SEXP (or NULL if not available)
  • class attribute: "rust_error_value"
  • __rust_error__ attribute: TRUE

Functions§

make_rust_error_value
Build a tagged error-value SEXP for transport across the Rust→R boundary.