From c682450652abed051c320f99e02b4ab450c7645c Mon Sep 17 00:00:00 2001 From: Yang Xiufeng Date: Tue, 26 Nov 2024 19:39:07 +0800 Subject: [PATCH] fix fmt of error. --- core/src/error_code.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/src/error_code.rs b/core/src/error_code.rs index 2fe4c556..8263f16b 100644 --- a/core/src/error_code.rs +++ b/core/src/error_code.rs @@ -38,12 +38,11 @@ pub struct ResponseWithErrorCode { impl Display for ErrorCode { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!( - f, - "[{}]{}.{}", - self.code, - self.message, - self.detail.clone().unwrap_or("".to_string()) - ) + match &self.detail { + Some(d) if !d.is_empty() => { + write!(f, "[{}]{}\n{}", self.code, self.message, d) + } + _ => write!(f, "[{}]{}", self.code, self.message,), + } } }