pub(crate) fn with_r_unwind_protect_sourced<F, R>(
f: F,
call: Option<SEXP>,
source: PanicSource,
) -> Rwhere
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.
Every outcome is raised through raise_rust_condition_via_stop, which
hands the tagged value with_r_unwind_protect would return to the R
helper the generated wrappers call, so the condition is the wrapper’s, with
its kind (#1768). This works even in ALTREP callback context, where there
is no R wrapper to inspect a tagged SEXP (Approach 3 from the issue-345
plan):
-
RCondition::Error(error!()) —kind = "error", its classes ahead of therust_*layering, itsdata =fields. -
RCondition::Conversion(arg_error!) —kind = "conversion", with the crate-class marker replaced in Rust by the classesminiextendr_init!registered: no generated R is there to resolve it. -
A generic panic —
kind = "panic", with the(at file:line)suffix. -
Warning,Message,Condition— a plain R error with a diagnostic message andkind = "panic".warning!()/message!()from ALTREP context cannot suspend execution for non-fatal signals; documented limitation.