MCPcopy Create free account
hub / github.com/bluejekyll/wasmtime-java / attempt_or_else

Function attempt_or_else

wasmtime-jni/src/wasm_exception.rs:23–40  ·  view source on GitHub ↗
(env: &JNIEnv, or: D, f: F)

Source from the content-addressed store, hash-verified

21
22#[track_caller]
23pub fn attempt_or_else<R, F, D>(env: &JNIEnv, or: D, f: F) -> R
24where
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
42pub fn exception_to_err<'j>(env: &JNIEnv<'j>, throwable: JThrowable<'j>) -> Error {
43 let reporter = ReportJThrowable { env, throwable };

Callers 2

attemptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…