Coder Social home page Coder Social logo

adityajain1030 / catch_panic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hermitsocialclub/catch_panic

0.0 1.0 0.0 21 KB

A helper macro for safe Java-Rust interop that "catches" Rust panics and rethrows them as Java exceptions.

License: Apache License 2.0

Shell 2.75% Rust 94.86% Batchfile 2.38%

catch_panic's Introduction

⚾ #[catch_panic]

Crates.io Documentation License

A helper macro for safe Java-Rust interop that "catches" Rust panics and rethrows them as Java exceptions.

Getting Started

Add catch_panic as a dependency to your Cargo.toml:

[dependencies]
catch_panic = "1.0.0"

Usage

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.

License

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.

catch_panic's People

Contributors

arc-blroth avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.