diff --git a/src/main.rs b/src/main.rs index c213a22..2c87279 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,9 +30,9 @@ fn fetch_inbox_top() -> imap::error::Result> { } else { return Ok(None); }; - let body = message.body().expect("message did not have a body!"); + let body = message.body().unwrap_or("NULL".as_bytes()); let body = std::str::from_utf8(body) - .expect("message was not valid utf-8") + .unwrap_or("NULL") .to_string(); let re = Regex::new(r"(insert string in message body, even 1 matching would do)+").unwrap(); if re.is_match(&body) { @@ -46,4 +46,4 @@ fn fetch_inbox_top() -> imap::error::Result> { imap_session.expunge().unwrap(); imap_session.logout()?; Ok(Some("logout".to_string())) -} \ No newline at end of file +}