diff --git a/components/outbound-wasi-http-v0.2.0/src/lib.rs b/components/outbound-wasi-http-v0.2.0/src/lib.rs index af6f572..d4dc399 100644 --- a/components/outbound-wasi-http-v0.2.0/src/lib.rs +++ b/components/outbound-wasi-http-v0.2.0/src/lib.rs @@ -51,14 +51,29 @@ impl bindings::Guest for Component { let response = match outgoing_handler::handle(outgoing_request, None) { Ok(r) => r, Err(e) => { - return_response(outparam, 500, e.to_string().as_bytes()); + return_response( + outparam, + 500, + format!("outgoing-handler/handle: {e}").as_bytes(), + ); return; } }; let response = loop { if let Some(response) = response.get() { - break response.unwrap().unwrap(); + let response = response.unwrap(); + match response { + Ok(r) => break r, + Err(e) => { + return_response( + outparam, + 500, + format!("incoming-response#get: {e}").as_bytes(), + ); + return; + } + }; } else { response.subscribe().block() } diff --git a/tests/outbound-wasi-http-v0.2.0-no-perms/test.json5 b/tests/outbound-wasi-http-v0.2.0-no-perms/test.json5 index d1df2f5..2b3fe7b 100644 --- a/tests/outbound-wasi-http-v0.2.0-no-perms/test.json5 +++ b/tests/outbound-wasi-http-v0.2.0-no-perms/test.json5 @@ -28,7 +28,7 @@ "optional": true } ], - "body": "ErrorCode::HttpRequestDenied" + "body": "incoming-response#get: ErrorCode::HttpRequestDenied" }, } ],