From d1af945de290be1ceb98bac987f7a684f2dc9e19 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 29 Apr 2022 22:56:22 +0000 Subject: [PATCH] get rid of unnecessary box --- src/main.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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(), } }