This commit is contained in:
2025-11-12 02:16:20 +01:00
parent cf070d35f0
commit 84734cca2f
20 changed files with 719 additions and 29 deletions
+7 -2
View File
@@ -40,6 +40,10 @@ impl AppError {
Self::new(StatusCode::UNAUTHORIZED, "unauthorized")
}
pub fn forbidden(message: impl Into<String>) -> Self {
Self::new(StatusCode::FORBIDDEN, message)
}
pub fn not_found() -> Self {
Self::new(StatusCode::NOT_FOUND, "resource not found")
}
@@ -91,8 +95,9 @@ impl From<diesel::result::Error> for AppError {
match value {
diesel::result::Error::NotFound => AppError::not_found(),
other => {
tracing::error!(error = ?other, "database operation failed");
AppError::internal("database operation failed")
let message = format!("database operation failed: {other}");
tracing::error!(error = ?other, message);
AppError::internal(message)
}
}
}