diff --git a/src/main.rs b/src/main.rs index 5524c8e0..888e1af5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ use tokio::sync::{mpsc, watch}; use tokio::time::sleep; use tracing::warn; use warp::Filter; +use warp::Reply; use crate::block_watcher::BlockWatcher; use crate::provider::JsonRpcRequest; @@ -355,12 +356,16 @@ async fn main() { } /// convert result into an http response. use this at the end of your warp filter -pub fn handle_anyhow_errors(res: anyhow::Result) -> Box { +/// TODO: using boxes can't be the best way. think about this more +fn handle_anyhow_errors( + res: anyhow::Result, +) -> warp::http::Response { match res { - Ok(r) => Box::new(r.into_response()), - Err(e) => Box::new(warp::reply::with_status( + Ok(r) => r.into_response(), + Err(e) => warp::reply::with_status( format!("{}", e), - reqwest::StatusCode::INTERNAL_SERVER_ERROR, - )), + warp::http::StatusCode::INTERNAL_SERVER_ERROR, + ) + .into_response(), } }