Skip to content

Commit

Permalink
Merge pull request #136 from zacharybonagura/master
Browse files Browse the repository at this point in the history
Fixed formatting errors, wasm error
  • Loading branch information
zacharybonagura authored Oct 19, 2024
2 parents 8b386a7 + 881e170 commit 74b98e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 2 additions & 3 deletions bindings/java/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ pub fn java_iterator_for_each<F: FnMut(JObject) -> jni::errors::Result<()>>(env:

/// Wraps a Rust function, converting both Result::Err and panic into instances of Java's RuntimeException.
/// Please use this on all native methods, otherwise a Rust panic/unwrap will crash the Java UI instead of popping a dialog box with the message.
#[allow(deprecated)]
pub fn with_thrown_errors<A, F: FnOnce(&JNIEnv) -> jni::errors::Result<A> + UnwindSafe>(env: &JNIEnv, f: F) -> A {
use std::panic::{set_hook, take_hook, PanicInfo};
use std::panic::{set_hook, take_hook, PanicHookInfo};
let old_hook = take_hook();
let (tx, rx) = std::sync::mpsc::channel::<String>();
let mtx = std::sync::Mutex::new(tx);
set_hook(Box::new(move |info: &PanicInfo| {
set_hook(Box::new(move |info: &PanicHookInfo| {
let mut msg = format!("Panic at {:?}", info.location());
if let Some(e) = info.payload().downcast_ref::<&str>() {
msg += &*format!(": {e:?}");
Expand Down
3 changes: 3 additions & 0 deletions web-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ derivative = "2.2.0"

[lib]
crate-type = ["cdylib", "rlib"]

[package.metadata.wasm-pack.profile.release]
wasm-opt = ["-Oz", "--enable-mutable-globals", "--enable-bulk-memory"]

0 comments on commit 74b98e2

Please sign in to comment.