From 1adcf95a19acca47156a8d705b718f3a0ca9a14d Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Fri, 9 Jul 2021 11:03:40 +0000 Subject: [PATCH] Dont panic incase the message couldnt be parsed Supply defaults to make the loop continue parsing Signed-off-by: baalajimaestro --- src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 +}