Skip to main content

repanic_if_rust_error

Function repanic_if_rust_error 

Source
pub unsafe fn repanic_if_rust_error(sexp: SEXP)
Expand description

Inspect a SEXP returned by a trait-ABI vtable shim and, if it is a tagged error value, re-panic with the reconstructed RCondition.

This is the “re-panic at the View boundary” step of Approach 1 from the issue-345 plan. The caller (a generated View method wrapper) does:

let result = { vtable_call };
::miniextendr_api::trait_abi::repanic_if_rust_error(result);
// ... convert result normally if we reach here

When sexp is a tagged error value:

  • RCondition::Error / RCondition::Warning / etc. → panic_any!(cond). The outer with_r_unwind_protect in the consumer’s C entry point will catch this and produce a tagged SEXP for the consumer’s R wrapper.

When sexp is a normal value: this is a no-op.

§Safety

Must be called from R’s main thread. sexp must be a valid (possibly tagged) SEXP.