Skip to content

Commit

Permalink
fix(api): return error on failed send_email
Browse files Browse the repository at this point in the history
  • Loading branch information
lajp committed Aug 23, 2024
1 parent 3851072 commit 4af68c9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/api/invoices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ pub async fn create(
.collect::<Vec<_>>(),
)?;

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)))
}
3 changes: 1 addition & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_)
Expand All @@ -47,7 +47,6 @@ impl IntoResponse for Error {
| Error::MultipartRejection(_)
| Error::JsonRejection(_)
| Error::UnsupportedFileFormat(_) => StatusCode::BAD_REQUEST,
Error::TypstError => StatusCode::INTERNAL_SERVER_ERROR,
};

(
Expand Down

0 comments on commit 4af68c9

Please sign in to comment.