I've worked through the examples which illustrate how to deal with errors created by the guest function, but I need to deal with errors created by host functions. My host is Go and my guest is Rust. The host function looks like this
extern "C" {
pub fn failable_function();
}
#[no_mangle]
pub extern fn this_will_fail() {
// ...even though I don't have an opportunity to deal with the error
unsafe{failable_function()}
// this doesn't work either because apparently its not a panic
let _ = std::panic::catch_unwind(||{
unsafe{failable_function()}
});
}
The problem is that when I call the guest'sthis_will_fail function from the host, which then calls the host's failable_function from the guest, there is no opportunity for the guest to handle the error, it just returns the error right back to the host. Ideally, I'd be able to get some kind of Result wrapper around the function.
Summary
I've worked through the examples which illustrate how to deal with errors created by the guest function, but I need to deal with errors created by host functions. My host is Go and my guest is Rust. The host function looks like this
And in my guest I'm doing this
The problem is that when I call the guest's
this_will_fail
function from the host, which then calls the host'sfailable_function
from the guest, there is no opportunity for the guest to handle the error, it just returns the error right back to the host. Ideally, I'd be able to get some kind ofResult
wrapper around the function.