diff --git a/crates/test-programs/wasi-http-tests/src/bin/outbound_request_unknown_method.rs b/crates/test-programs/wasi-http-tests/src/bin/outbound_request_unknown_method.rs index 727294861b00..a2ab5e48dc02 100644 --- a/crates/test-programs/wasi-http-tests/src/bin/outbound_request_unknown_method.rs +++ b/crates/test-programs/wasi-http-tests/src/bin/outbound_request_unknown_method.rs @@ -18,6 +18,6 @@ async fn run() { let error = res.unwrap_err(); assert_eq!( error.to_string(), - "Error::Invalid(\"unknown method OTHER\")" + "Error::InvalidUrl(\"unknown method OTHER\")" ); } diff --git a/crates/test-programs/wasi-http-tests/src/bin/outbound_request_unsupported_scheme.rs b/crates/test-programs/wasi-http-tests/src/bin/outbound_request_unsupported_scheme.rs index c8a66b7da648..482550627e8d 100644 --- a/crates/test-programs/wasi-http-tests/src/bin/outbound_request_unsupported_scheme.rs +++ b/crates/test-programs/wasi-http-tests/src/bin/outbound_request_unsupported_scheme.rs @@ -18,6 +18,6 @@ async fn run() { let error = res.unwrap_err(); assert_eq!( error.to_string(), - "Error::Invalid(\"unsupported scheme WS\")" + "Error::InvalidUrl(\"unsupported scheme WS\")" ); } diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index 570d229cf7b2..8c9e6358fb55 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -50,7 +50,7 @@ impl outgoing_handler::Host for T { crate::bindings::http::types::Method::Trace => Method::TRACE, crate::bindings::http::types::Method::Patch => Method::PATCH, crate::bindings::http::types::Method::Other(method) => { - return Ok(Err(outgoing_handler::Error::Invalid(format!( + return Ok(Err(outgoing_handler::Error::InvalidUrl(format!( "unknown method {method}" )))); } @@ -60,7 +60,7 @@ impl outgoing_handler::Host for T { Scheme::Http => (false, "http://", 80), Scheme::Https => (true, "https://", 443), Scheme::Other(scheme) => { - return Ok(Err(outgoing_handler::Error::Invalid(format!( + return Ok(Err(outgoing_handler::Error::InvalidUrl(format!( "unsupported scheme {scheme}" )))) } diff --git a/crates/wasi-http/src/lib.rs b/crates/wasi-http/src/lib.rs index c6b072b1e60f..96a6fb835fb1 100644 --- a/crates/wasi-http/src/lib.rs +++ b/crates/wasi-http/src/lib.rs @@ -1,6 +1,4 @@ pub use crate::types::{WasiHttpCtx, WasiHttpView}; -use core::fmt::Formatter; -use std::fmt::{self, Display}; pub mod body; pub mod http_impl; @@ -28,27 +26,6 @@ pub mod bindings { pub use wasi::http; } -impl std::error::Error for crate::bindings::http::types::Error {} - -impl Display for crate::bindings::http::types::Error { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - match self { - crate::bindings::http::types::Error::InvalidUrl(m) => { - write!(f, "[InvalidUrl] {}", m) - } - crate::bindings::http::types::Error::ProtocolError(m) => { - write!(f, "[ProtocolError] {}", m) - } - crate::bindings::http::types::Error::TimeoutError(m) => { - write!(f, "[TimeoutError] {}", m) - } - crate::bindings::http::types::Error::UnexpectedError(m) => { - write!(f, "[UnexpectedError] {}", m) - } - } - } -} - impl From for crate::bindings::http::types::Error { fn from(err: wasmtime_wasi::preview2::TableError) -> Self { Self::UnexpectedError(err.to_string()) diff --git a/crates/wasi-http/wit/deps/http/outgoing-handler.wit b/crates/wasi-http/wit/deps/http/outgoing-handler.wit index 3e03327d742b..43bd0035fc06 100644 --- a/crates/wasi-http/wit/deps/http/outgoing-handler.wit +++ b/crates/wasi-http/wit/deps/http/outgoing-handler.wit @@ -6,14 +6,7 @@ // that takes a `request` parameter and returns a `response` result. // interface outgoing-handler { - use types.{outgoing-request, request-options, future-incoming-response} - - // FIXME: we would want to use the types.error here but there is a - // wasmtime-wit-bindgen bug that prevents us from using the same error in - // the two different interfaces, right now... - variant error { - invalid(string) - } + use types.{outgoing-request, request-options, future-incoming-response, error} // The parameter and result types of the `handle` function allow the caller // to concurrently stream the bodies of the outgoing request and the incoming diff --git a/crates/wasi/wit/deps/http/outgoing-handler.wit b/crates/wasi/wit/deps/http/outgoing-handler.wit index 3e03327d742b..43bd0035fc06 100644 --- a/crates/wasi/wit/deps/http/outgoing-handler.wit +++ b/crates/wasi/wit/deps/http/outgoing-handler.wit @@ -6,14 +6,7 @@ // that takes a `request` parameter and returns a `response` result. // interface outgoing-handler { - use types.{outgoing-request, request-options, future-incoming-response} - - // FIXME: we would want to use the types.error here but there is a - // wasmtime-wit-bindgen bug that prevents us from using the same error in - // the two different interfaces, right now... - variant error { - invalid(string) - } + use types.{outgoing-request, request-options, future-incoming-response, error} // The parameter and result types of the `handle` function allow the caller // to concurrently stream the bodies of the outgoing request and the incoming