From 11a7aff8e0637b0707614c128ff976b02f323483 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 23 Dec 2022 12:12:17 -0800 Subject: [PATCH] don't unwrap. still might be more errors to handle though --- web3_proxy/src/frontend/rpc_proxy_ws.rs | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/web3_proxy/src/frontend/rpc_proxy_ws.rs b/web3_proxy/src/frontend/rpc_proxy_ws.rs index 11d43e74..6a189d94 100644 --- a/web3_proxy/src/frontend/rpc_proxy_ws.rs +++ b/web3_proxy/src/frontend/rpc_proxy_ws.rs @@ -245,21 +245,19 @@ async fn handle_socket_payload( Ok(response.into()) } - _ => { - let x = app - .proxy_web3_rpc(authorization.clone(), json_request.into()) - .await - // TODO: DO NOT UNWRAP HERE! ANY FAILING MESSAGES SHOULD KEEP THE CONNECTION! - .map_or_else( - |err| { - // need to think about this - todo!("do something to convert FrontendErrorResponse into a JsonRpcForwardedResponseEnum"); - }, - |(response, _)| response - ); - - Ok(x) - } + _ => app + .proxy_web3_rpc(authorization.clone(), json_request.into()) + .await + .map_or_else( + |err| match err { + FrontendErrorResponse::Anyhow(err) => Err(err), + _ => { + error!("handle this better! {:?}", err); + Err(anyhow::anyhow!(format!("unexpected error! {:?}", err))) + } + }, + |(response, _)| Ok(response), + ), }; (id, response)