-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Trigger a trap from the context of an import #1426
Comments
I think @MarkMcCaskey might be able to help you with that :) |
Good question! This is something that should be documented more clearly, in Rust you can do it by returning a You can look at our WASI implementation for an example of this: https://github.com/wasmerio/wasmer/blob/master/lib/wasi/src/syscalls/mod.rs#L2506-L2509 We special cased it so that the failure value of a |
Oh, that's cool :D Thanks for the answer! |
In Wasmer 0.16.* it'll be returned through RuntimeError and can be accessed by doing The runtime error will be returned at the site where you called into Wasm.
|
Thanks for the help on this issue! |
The API changed a bit preparing to Wasmer 1.0. We will create an example soon |
Summary
This isn't clear to me from the documentation, although i believe the answer would be simple. How does one trigger a trap during an import? The imported functions that are provided to the
import
macro must return simple types (i32, u32, ...) and can't return a Result of either a Value or a Trap.Additional details
I would like to basically "throw" a custom error enumeration during import execution which would abort the module, and catch it outside of that context, where i can analyze the thrown error.
The text was updated successfully, but these errors were encountered: