Skip to main content

guarded_ffi_call_with_fallback

Function guarded_ffi_call_with_fallback 

Source
pub fn guarded_ffi_call_with_fallback<F, R>(
    f: F,
    fallback: R,
    source: PanicSource,
) -> R
where F: FnOnce() -> R,
Expand description

Execute f inside a CatchUnwind guard, returning fallback on panic.

Unlike guarded_ffi_call with CatchUnwind (which diverges via Rf_error), this variant returns the fallback value instead of raising an R error. This is needed for connection trampolines where panicking through R/C frames is UB but raising an R error is also undesirable (the caller expects a return value indicating failure).

Telemetry is fired before returning the fallback.