(env: &JNIEnv, or: D, f: F)
| 21 | |
| 22 | #[track_caller] |
| 23 | pub fn attempt_or_else<R, F, D>(env: &JNIEnv, or: D, f: F) -> R |
| 24 | where |
| 25 | D: FnOnce() -> R, |
| 26 | F: FnOnce(&JNIEnv) -> Result<R, Error>, |
| 27 | { |
| 28 | let r = f(env); |
| 29 | |
| 30 | match r { |
| 31 | Ok(ok) => ok, |
| 32 | Err(err) => { |
| 33 | let msg = format!("Error in WASM Binding: {:?}", err); |
| 34 | warn!("{}", msg); |
| 35 | env.throw_new("net/bluejekyll/wasmtime/WasmtimeException", msg) |
| 36 | .expect("failed to throw exception"); |
| 37 | or() |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | pub fn exception_to_err<'j>(env: &JNIEnv<'j>, throwable: JThrowable<'j>) -> Error { |
| 43 | let reporter = ReportJThrowable { env, throwable }; |
no outgoing calls
no test coverage detected
searching dependent graphs…