diff --git a/internal/standup-bot/src/main.rs b/internal/standup-bot/src/main.rs index c05146d9f..86f02618c 100644 --- a/internal/standup-bot/src/main.rs +++ b/internal/standup-bot/src/main.rs @@ -46,10 +46,18 @@ async fn main() { } if let Err(e) = redis::client::set_last_standup(Utc::now()).await { - eprintln!("Failed to save standup to Redis: {e:#?}"); + eprintln!("Failed to save standup to Redis"); + eprintln!("Error: {}", e); + eprintln!("Debug: {:#?}", e); } } - Err(e) => eprintln!("Failed to get last standup from Redis: {e:#?}"), + Err(e) => { + eprintln!("==============================================="); + eprintln!("Failed to get last standup from Redis"); + eprintln!("Error: {}", e); + eprintln!("Debug: {:#?}", e); + eprintln!("==============================================="); + } } }); } diff --git a/internal/standup-bot/src/redis/error.rs b/internal/standup-bot/src/redis/error.rs index 6de8aafc6..21069a106 100644 --- a/internal/standup-bot/src/redis/error.rs +++ b/internal/standup-bot/src/redis/error.rs @@ -1,5 +1,6 @@ use chrono::ParseError; use redis::RedisError; +use std::fmt; #[derive(Debug)] #[allow(dead_code)] @@ -8,6 +9,37 @@ pub enum RedisClientError { DateTimeParse(ParseError), } +impl fmt::Display for RedisClientError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + RedisClientError::Redis(e) => { + write!(f, "RedisError: {:?}", e)?; + write!(f, "\n Category: {:?}", e.category())?; + write!(f, "\n Kind: {:?}", e.kind())?; + write!( + f, + "\n is_connection_dropped: {}", + e.is_connection_dropped() + )?; + write!(f, "\n is_timeout: {}", e.is_timeout())?; + write!( + f, + "\n is_connection_refusal: {}", + e.is_connection_refusal() + )?; + write!(f, "\n is_io_error: {}", e.is_io_error())?; + if let Some(detail) = e.detail() { + write!(f, "\n Detail: {}", detail)?; + } + Ok(()) + } + RedisClientError::DateTimeParse(e) => write!(f, "DateTimeParse: {:?}", e), + } + } +} + +impl std::error::Error for RedisClientError {} + impl From for RedisClientError { fn from(value: RedisError) -> Self { RedisClientError::Redis(value)