From be423aabb6d903c3ce714a952d55376e60731e2b Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Fri, 17 Apr 2026 14:42:51 +0800 Subject: [PATCH] feat(error): add error print info to system command --- libs/service/error.rs | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/libs/service/error.rs b/libs/service/error.rs index 11974d6..4a971ff 100644 --- a/libs/service/error.rs +++ b/libs/service/error.rs @@ -196,14 +196,38 @@ impl AppError { AppError::NotFound(s) => s.clone(), AppError::BadRequest(s) => s.clone(), AppError::Forbidden(s) => s.clone(), - AppError::DatabaseError(_) => "A database error occurred".to_string(), - AppError::PasswordHashError(_) => "A password processing error occurred".to_string(), - AppError::GitError(_) => "A git operation failed".to_string(), - AppError::SerdeError(_) => "A data parsing error occurred".to_string(), - AppError::Io(_) => "A file system error occurred".to_string(), - AppError::InternalServerError(_) => "An internal error occurred".to_string(), - AppError::AvatarUploadError(_) => "An avatar upload error occurred".to_string(), - AppError::Conflict(_) => "Resource conflict".to_string(), + AppError::DatabaseError(s) => { + println!("[System] {:?}", s); + "A database error occurred".to_string() + } + AppError::PasswordHashError(s) => { + println!("[System] {:?}", s); + "A password processing error occurred".to_string() + } + AppError::GitError(s) => { + println!("[System] {:?}", s); + "A git error occurred".to_string() + } + AppError::SerdeError(s) => { + println!("[System] {:?}", s); + "A data parsing error occurred".to_string() + } + AppError::Io(s) => { + println!("[System] {:?}", s); + "A file system error occurred".to_string() + } + AppError::InternalServerError(e) => { + println!("[System] {:?}", e); + "An internal server error occurred".to_string() + } + AppError::AvatarUploadError(s) => { + println!("[System] {:?}", s); + "An avatar upload error occurred".to_string() + } + AppError::Conflict(s) => { + println!("[System] {:?}", s); + "Resource conflict".to_string() + } _ => self.slug().to_string(), } }