From 67a57fa6221ed9bc6920a881784b308d4f5c3e6e Mon Sep 17 00:00:00 2001 From: batsumaru <> Date: Fri, 16 Oct 2026 15:47:04 +0900 Subject: Add csv export --- src/error.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 232d588..d16106a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -9,6 +9,7 @@ use serde_json::json; pub enum AppError { BadRequest(&'static str), Conflict, + Csv(csv::Error), Database(sqlx::Error), MethodNotAllowed, NotFound, @@ -25,6 +26,12 @@ impl From for AppError { } } +impl From for AppError { + fn from(e: csv::Error) -> Self { + AppError::Csv(e) + } +} + impl From for AppError { fn from(rejection: JsonRejection) -> Self { AppError::Rejection(rejection.status(), rejection.body_text()) @@ -48,6 +55,13 @@ impl IntoResponse for AppError { let (status, message) = match self { AppError::BadRequest(message) => (StatusCode::BAD_REQUEST, message.to_owned()), AppError::Conflict => (StatusCode::CONFLICT, "already exists".to_owned()), + AppError::Csv(e) => { + tracing::error!("csv error: {e}"); + ( + StatusCode::INTERNAL_SERVER_ERROR, + "internal server error".to_owned(), + ) + } AppError::Database(e) => { tracing::error!("database error: {e}"); ( -- cgit v1.3