diff --git a/Cargo.lock b/Cargo.lock index 7a6912db17a9598d1c001488355e0c9a28b1db7f..6d3896cc6b510374c596c4135353e74ed54ad23a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -585,7 +585,7 @@ checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" [[package]] name = "drone" -version = "0.2.5" +version = "0.2.6" dependencies = [ "actix-cors", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index 9bd3feb07e39c8922356a47e5e4eed79d2c55ab5..c152b39f85af6b32560f9ec3b179f6d9a3c0f24b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "drone" -version = "0.2.5" +version = "0.2.6" edition = "2021" authors = ["Deathwing <hi@deathwing.me>"] description = "A caching reverse-proxy application for the Hive blockchain." diff --git a/src/main.rs b/src/main.rs index 43377a9bac1226c8948c0168520ccf59c40336ac..e09df4c90dc3b08480e9c707eff9726d54470682 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use reqwest::{Client, ClientBuilder}; use serde::{Deserialize, Serialize, Serializer}; use serde_json::Value; use serde_with::{serde_as, DurationSeconds}; -use std::{sync::Mutex, time::Duration}; +use std::{sync::Mutex, time::Duration, fmt::Display}; const DRONE_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -110,6 +110,16 @@ impl Endpoints { } } +impl Display for Endpoints { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Endpoints::HAF => write!(f, " Endpoint: HAF"), + Endpoints::HAFAH => write!(f, " Endpoint: HAFAH"), + Endpoints::HIVEMIND => write!(f, " Endpoint: HIVEMIND"), + } + } +} + #[async_recursion] async fn handle_request( request: &APIRequest, @@ -221,12 +231,14 @@ async fn handle_request( { Ok(response) => response, Err(err) => { + let mut error_message = err.without_url().to_string(); + error_message.push_str(&endpoints.to_string()); return Err(ErrorStructure { jsonrpc: request.jsonrpc.clone(), id : request.id, code: -32700, message: format!("Unable to send request to endpoint."), - error: ErrorField::Message(err.to_string()), + error: ErrorField::Message(error_message), }) } };