Function magnus::rb_sys::catch_unwind

source ·
pub fn catch_unwind<F, T>(func: F) -> Result<T, Error>
where F: FnOnce() -> T + UnwindSafe,
Available on crate feature rb-sys only.
Expand description

Attempts to catch cases of Rust unwinding, converting to a fatal Error.

This should not be used to catch and discard panics.

This function can be used to ensure Rust panics do not cross over to Ruby. This will convert a panic to a Ruby fatal Error that can then be used to safely terminate Ruby.

All functions exposed by Magnus that allow Ruby to call Rust code already use this internally, this should only be required to wrap functions/closures given directly to rb-sys.