| Crates.io | catch_panic |
| lib.rs | catch_panic |
| version | 1.0.0 |
| created_at | 2022-07-25 23:29:02.992097+00 |
| updated_at | 2022-07-25 23:29:02.992097+00 |
| description | A helper macro for safe Java-Rust interop that "catches" Rust panics and rethrows them as Java exceptions. |
| homepage | |
| repository | https://github.com/HermitSocialClub/catch_panic |
| max_upload_size | |
| id | 632864 |
| size | 13,134 |
A helper macro for safe Java-Rust interop that "catches" Rust panics and rethrows them as Java exceptions.
Add catch_panic as a dependency to your Cargo.toml:
[dependencies]
catch_panic = "1.0.0"
Attach #[catch_panic] to a JNI callback to have panics converted into RuntimeExceptions:
use jni::JNIEnv;
use catch_panic::catch_panic;
#[no_mangle]
#[catch_panic]
pub extern "C" fn Java_com_example_Example_panic(_env: JNIEnv) {
panic!("everything is not fine");
}
See the docs for macro options and more information.
This crate is dual-licensed under either:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
The code in this crate is a derivative of code from HermitSocialClub/HermitRepo,
specifically the files ProjectTomato/tomato_macros/src/lib.rs and
ProjectTomato/tomato/src/util.rs.
All authors of these two files have agreed to relicense the original code under the above license.