macro: wrap xs calls in std::panic::catch_unwind

This causes panics to "croak" in perl, rather than aborting the entire
process.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2025-03-17 10:26:48 +01:00
parent 95d8d56b0a
commit d7a1add485

View File

@ -290,7 +290,15 @@ pub fn handle_function(
argmark.set_stack();
}
#handle_return
let res = std::panic::catch_unwind(move || {
#handle_return
});
match res {
Ok(res) => res,
Err(_panic) => Err(::perlmod::Value::new_string("rust function panicked")
.into_mortal()
.into_raw()),
}
}
};