From 7cef05a7f92fbb6ca003d2d1526a664e605c3e9d Mon Sep 17 00:00:00 2001 From: Delta1925 Date: Tue, 18 Apr 2023 23:49:18 +0200 Subject: [PATCH] Add special mail when failing to send mail --- backend/src/confirmation.rs | 6 ++++-- backend/src/errors.rs | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/confirmation.rs b/backend/src/confirmation.rs index 992a06b..3c0914e 100644 --- a/backend/src/confirmation.rs +++ b/backend/src/confirmation.rs @@ -77,6 +77,8 @@ pub fn send_confirmation_email(address: &str, action: &Action, token: &str) -> R let email = log_err!(email, warn)?; - log_err!(MAILER.send(&email), warn)?; - Ok(()) + match log_err!(MAILER.send(&email), warn){ + Ok(_) => Ok(()), + Err(_) => Err(SpecialErrors::MailErr)? + } } diff --git a/backend/src/errors.rs b/backend/src/errors.rs index 284a1e8..bdce6b7 100644 --- a/backend/src/errors.rs +++ b/backend/src/errors.rs @@ -44,6 +44,8 @@ pub enum SpecialErrors { InexistingUser, #[error("The key is either expired or uses an obsolete cipher!")] InvalidCert, + #[error("Error while sending email")] + MailErr, #[error("Could not parse keyblock")] MalformedCert, #[error("Could not parse user email: malformed email")] @@ -94,6 +96,7 @@ impl ResponseError for CompatErr { SpecialErrors::InexistingUser => StatusCode::NOT_FOUND, SpecialErrors::InvalidCert => StatusCode::BAD_REQUEST, SpecialErrors::EmailMissing => StatusCode::BAD_REQUEST, + SpecialErrors::MailErr => StatusCode::INTERNAL_SERVER_ERROR, SpecialErrors::MalformedCert => StatusCode::BAD_REQUEST, SpecialErrors::MalformedEmail => StatusCode::BAD_REQUEST, SpecialErrors::MissingFile => StatusCode::NOT_FOUND,