Skip to content
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 replace the custom_error feature #435

Closed
Maaarcocr opened this issue Nov 17, 2022 · 4 comments
Closed

How to replace the custom_error feature #435

Maaarcocr opened this issue Nov 17, 2022 · 4 comments

Comments

@Maaarcocr
Copy link

in #355 the custom_error flag was removed. Is there any substitute for such feature in the newer versions on wit-bindgen? Is this now unnecessary? If so, why?

If there is a plan to add something like this back, I would also be happy to spend some time trying to get it done!

@alexcrichton
Copy link
Member

Pat's working on error-handling for wit-bindgen by prototyping this first in wiggle as part of bytecodealliance/wasmtime#5276 and bytecodealliance/wasmtime#5279 and I believe he plans on carrying over that work to this repository in short order.

@pchickey
Copy link
Contributor

Yep I have the PR half-done right now, it should be up today or tomorrow

@Maaarcocr
Copy link
Author

Thank you!!

@alexcrichton
Copy link
Member

Looking back I think this was more-or-less done in #388 where Wasmtime-hosted functions by default return anyhow::Result<T> now where T is the result of the function and all other errors are traps. For result<_, _>-returning functions in *.wit that now translates to Resul<T, Error<E>> where Error<E> can be created from E or from anyhow::Error (more-or-less) where the former represents something to return to the guest and the latter represents a trap. You can implement custom From<MyType> for Error<E> conversions to weave custom errors into an E as necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants