Macro janetrs::jcatch[][src]

macro_rules! jcatch {
    ($e:expr) => { ... };
}
Expand description

Execute a JanetCFunction 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()
}