From 4198cd81f3d3dfb911a783c354bc0b5be5b96d4d Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Thu, 2 May 2024 11:09:50 +0200 Subject: [PATCH] including proper reqwest error message --- explorer-api/src/mix_node/http.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/explorer-api/src/mix_node/http.rs b/explorer-api/src/mix_node/http.rs index 6f45c65c6e..d93dce998c 100644 --- a/explorer-api/src/mix_node/http.rs +++ b/explorer-api/src/mix_node/http.rs @@ -11,7 +11,7 @@ use crate::mix_node::models::{ use crate::state::ExplorerApiStateContext; use nym_explorer_api_requests::PrettyDetailedMixNodeBond; use nym_mixnet_contract_common::{Delegation, MixId}; -use reqwest::Error as ReqwestError; +use reqwest::{Error as ReqwestError, Response, StatusCode}; use rocket::response::status::NotFound; use rocket::serde::json::Json; use rocket::{Route, State}; @@ -61,8 +61,14 @@ async fn get_mix_node_stats(host: &str, port: u16) -> Result().await; } - Err("failed to fetch stats from both endpoints") + Err(reqwest::Error::from( + reqwest::Response::builder() + .status(StatusCode::INTERNAL_SERVER_ERROR) + .body("Failed to fetch stats from both endpoints".into()) + .unwrap() + )) } + #[openapi(tag = "mix_nodes")] #[get("/")] pub(crate) async fn get_by_id(