macro_rules! jcatch { ($e:expr) => { ... }; }
Expand description
Execute a function (JanetCFunction
, Rust function or extern C function) and catch
any janet panic that may happen as a Result
.
§Examples
ⓘ
use janetrs::{jcatch, jpanic, Janet};
fn panic_fn() {
jpanic!("Help!");
}
#[janet_fn]
fn test(args: &mut [Janet]) -> Janet {
let res = jcatch!(panic_fn());
dbg!(res);
Janet::nil()
}