From 4af68c96b6427b0d671b58c450e8294850ba70e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luukas=20P=C3=B6rtfors?= Date: Fri, 23 Aug 2024 23:57:49 +0300 Subject: [PATCH] fix(api): return error on failed send_email --- src/api/invoices.rs | 7 +------ src/error.rs | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/api/invoices.rs b/src/api/invoices.rs index 601a0fc..945feca 100644 --- a/src/api/invoices.rs +++ b/src/api/invoices.rs @@ -142,11 +142,6 @@ pub async fn create( .collect::>(), )?; - tokio::task::spawn(async move { - if let Err(e) = client.send_mail(multipart.data).await { - error!("Sending invoice failed: {}", e); - } - }); - + client.send_mail(multipart.data).await?; Ok((StatusCode::CREATED, axum::Json(orig))) } diff --git a/src/error.rs b/src/error.rs index 631eca3..37960f8 100644 --- a/src/error.rs +++ b/src/error.rs @@ -38,7 +38,7 @@ impl IntoResponse for Error { error!(%self); let status = match self { - Error::InternalServerError(_) | Error::ReqwestError(_) => { + Error::InternalServerError(_) | Error::ReqwestError(_) | Error::TypstError => { StatusCode::INTERNAL_SERVER_ERROR } Error::JsonError(_) @@ -47,7 +47,6 @@ impl IntoResponse for Error { | Error::MultipartRejection(_) | Error::JsonRejection(_) | Error::UnsupportedFileFormat(_) => StatusCode::BAD_REQUEST, - Error::TypstError => StatusCode::INTERNAL_SERVER_ERROR, }; (