Skip to content

Commit

Permalink
Remove unnecessary unwraps
Browse files Browse the repository at this point in the history
  • Loading branch information
marcua committed Sep 19, 2023
1 parent f5a4656 commit c1e687e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ async fn send_email(
config: &AybConfigEmail,
e2e_testing_on: bool,
) -> Result<(), AybError> {
// TODO(marcua): Any way to be more careful about these unwraps?
let email = Message::builder()
.from(config.from.parse().unwrap())
.reply_to(config.reply_to.parse().unwrap())
.to(to.parse().unwrap())
.from(config.from.parse()?)
.reply_to(config.reply_to.parse()?)
.to(to.parse()?)
.subject(subject)
.header(ContentType::TEXT_PLAIN)
.body(body)
Expand Down
9 changes: 9 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use actix_web;
use derive_more::{Display, Error};
use fernet;
use lettre;
use quoted_printable;
use reqwest;
use rusqlite;
Expand Down Expand Up @@ -28,6 +29,14 @@ impl From<fernet::DecryptionError> for AybError {
}
}

impl From<lettre::address::AddressError> for AybError {
fn from(cause: lettre::address::AddressError) -> Self {
AybError {
message: format!("Invalid email address: {}", cause),
}
}
}

impl From<quoted_printable::QuotedPrintableError> for AybError {
fn from(cause: quoted_printable::QuotedPrintableError) -> Self {
AybError {
Expand Down

0 comments on commit c1e687e

Please sign in to comment.