feat(error): add error print info to system command
Some checks are pending
CI / Rust Lint & Check (push) Waiting to run
CI / Rust Tests (push) Waiting to run
CI / Frontend Lint & Type Check (push) Waiting to run
CI / Frontend Build (push) Blocked by required conditions

This commit is contained in:
ZhenYi 2026-04-17 14:42:51 +08:00
parent 0d9256793c
commit be423aabb6

View File

@ -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(),
}
}