diff --git a/crates/generate/src/funcs.rs b/crates/generate/src/funcs.rs index e788032e66..eb3a02ac19 100644 --- a/crates/generate/src/funcs.rs +++ b/crates/generate/src/funcs.rs @@ -62,7 +62,7 @@ pub fn define_func(names: &Names, func: &witx::InterfaceFunc) -> TokenStream { }; let err_typename = names.type_ref(&tref, anon_lifetime()); quote! { - let e = wiggle_runtime::GuestError::InFunc { funcname: #funcname, location: #location, err: Box::new(e) }; + let e = wiggle_runtime::GuestError::InFunc { funcname: #funcname, location: #location, err: Box::new(e.into()) }; let err: #err_typename = wiggle_runtime::GuestErrorType::from_error(e, ctx); return #abi_ret::from(err); } diff --git a/crates/runtime/src/error.rs b/crates/runtime/src/error.rs index 9c9e8a8e9a..14c48be1b9 100644 --- a/crates/runtime/src/error.rs +++ b/crates/runtime/src/error.rs @@ -27,6 +27,8 @@ pub enum GuestError { #[source] err: Box, }, - #[error("Invalid UTF-8 encountered")] - InvalidUtf8(#[from] std::str::Utf8Error), + #[error("Invalid UTF-8 encountered: {0:?}")] + InvalidUtf8(#[from] ::std::str::Utf8Error), + #[error("Int conversion error: {0:?}")] + TryFromIntError(#[from] ::std::num::TryFromIntError), }