diff --git a/crates/wasi-http/src/error.rs b/crates/wasi-http/src/error.rs index 8a2c2cf0fcad..9c0a562b4189 100644 --- a/crates/wasi-http/src/error.rs +++ b/crates/wasi-http/src/error.rs @@ -112,3 +112,9 @@ pub fn hyper_response_error(err: hyper::Error) -> ErrorCode { ErrorCode::HttpProtocolError } + +impl From for ErrorCode { + fn from(err: hyper::Error) -> Self { + hyper_response_error(err) + } +} diff --git a/crates/wasi-http/src/types.rs b/crates/wasi-http/src/types.rs index 0eb1d31a9389..61f4d0a9d118 100644 --- a/crates/wasi-http/src/types.rs +++ b/crates/wasi-http/src/types.rs @@ -2,7 +2,7 @@ //! implementation of the wasi-http API. use crate::{ - bindings::http::types::{self, Method, Scheme}, + bindings::http::types::{self, ErrorCode, Method, Scheme}, body::{HostIncomingBody, HyperIncomingBody, HyperOutgoingBody}, }; use anyhow::bail; @@ -92,11 +92,12 @@ pub trait WasiHttpView { req: hyper::Request, ) -> wasmtime::Result> where - B: Body + Send + 'static, + B: Body + Send + 'static, + B::Error: Into, Self: Sized, { let (parts, body) = req.into_parts(); - let body = body.map_err(crate::hyper_response_error).boxed_unsync(); + let body = body.map_err(Into::into).boxed_unsync(); let body = HostIncomingBody::new( body, // TODO: this needs to be plumbed through