Skip to main content

with_r_unwind_protect_sourced

Function with_r_unwind_protect_sourced 

Source
pub(crate) fn with_r_unwind_protect_sourced<F, R>(
    f: F,
    call: Option<SEXP>,
    source: PanicSource,
) -> R
where F: FnOnce() -> R,
Expand description

Like with_r_unwind_protect_or_raise, but reports panics with a custom [PanicSource].

Used by guarded_altrep_call so that panics inside ALTREP callbacks with AltrepGuard::RUnwind are still attributed to PanicSource::Altrep.

Handles crate::condition::RCondition payloads:

  • RCondition::Error — routes through raise_rust_condition_via_stop which Rf_evals stop(structure(..., class = c("rust_error", ...))). This gives full rust_* class layering even in ALTREP callback context where there is no R wrapper to inspect a tagged SEXP (Approach 3 from the issue-345 plan). Custom class = "..." from error!() is preserved in the class vector.

  • Warning, Message, Condition — convert to a plain R error with a diagnostic message. warning!()/message!() from ALTREP context cannot suspend execution for non-fatal signals; documented limitation.