From 358dff152daf0208d1379c4467f35497ff8cf1b7 Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 11 Jun 2026 13:19:18 +0800 Subject: [PATCH] fix(error): use Debug formatting in AppError logs for full error chain visibility --- src/api/error.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/api/error.rs b/src/api/error.rs index 0c87758..c8c6319 100644 --- a/src/api/error.rs +++ b/src/api/error.rs @@ -13,19 +13,19 @@ pub enum AppError { #[cfg(feature = "server")] impl AppError { - pub fn db_conn(e: impl std::fmt::Display) -> Self { - tracing::error!("DB connection failed: {e}"); - AppError::DbConn(e.to_string()) + pub fn db_conn(e: impl std::fmt::Debug) -> Self { + tracing::error!("DB connection failed: {e:?}"); + AppError::DbConn(format!("{e:?}")) } - pub fn query(e: impl std::fmt::Display) -> Self { - tracing::error!("Query failed: {e}"); - AppError::Query(e.to_string()) + pub fn query(e: impl std::fmt::Debug) -> Self { + tracing::error!("Query failed: {e:?}"); + AppError::Query(format!("{e:?}")) } - pub fn tx(e: impl std::fmt::Display) -> Self { - tracing::error!("Transaction failed: {e}"); - AppError::Transaction(e.to_string()) + pub fn tx(e: impl std::fmt::Debug) -> Self { + tracing::error!("Transaction failed: {e:?}"); + AppError::Transaction(format!("{e:?}")) } }