including proper reqwest error message

This commit is contained in:
Tommy Verrall
2024-05-02 11:09:50 +02:00
parent bbf57482fc
commit 4198cd81f3
+8 -2
View File
@@ -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<NodeStats, ReqwestE
return response.json::<NodeStats>().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("/<mix_id>")]
pub(crate) async fn get_by_id(