Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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\")"
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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\")"
);
}
4 changes: 2 additions & 2 deletions crates/wasi-http/src/http_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<T: WasiHttpView> 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}"
))));
}
Expand All @@ -60,7 +60,7 @@ impl<T: WasiHttpView> 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}"
))))
}
Expand Down
23 changes: 0 additions & 23 deletions crates/wasi-http/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<wasmtime_wasi::preview2::TableError> for crate::bindings::http::types::Error {
fn from(err: wasmtime_wasi::preview2::TableError) -> Self {
Self::UnexpectedError(err.to_string())
Expand Down
9 changes: 1 addition & 8 deletions crates/wasi-http/wit/deps/http/outgoing-handler.wit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions crates/wasi/wit/deps/http/outgoing-handler.wit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down