diff --git a/log4rs.yaml b/log4rs.yaml index ffdc372..1e80189 100644 --- a/log4rs.yaml +++ b/log4rs.yaml @@ -15,7 +15,7 @@ appenders: # Set the default logging level to "warn" and attach the "stdout" appender to the root root: - level: info + level: debug appenders: - stdout diff --git a/src/main.rs b/src/main.rs index 0c67e51..8d12e6a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use std::fmt::Display; use std::net::TcpStream; use std::path::Path; -use log::{debug, info}; +use log::{debug, error, info, warn}; use reqwest::blocking::Response; use serde::{Deserialize, Serialize}; @@ -31,7 +31,13 @@ fn process_mailbox(imap_ip: &str, mailbox: &Mailbox) { } }; - imap_session.select("INBOX").unwrap(); + match imap_session.select("INBOX") { + Err(error) => { + error!("Unable to select INBOX: {}", error); + return; + } + _ => {} + } let message = get_emails(&mut imap_session); @@ -105,11 +111,16 @@ fn get_emails(imap_session: &mut imap::Session) -> Option, imap_session: &mut imap::Session) { for ordinal in ordinals { - imap_session.store(format!("{}", ordinal), "+FLAGS (\\Deleted)") - .expect("Couldn't delete message"); + match imap_session.store(format!("{}", ordinal), "+FLAGS (\\Deleted)") { + Err(error) => warn!("Failed to delete message {ordinal}: {error}"), + _ => {} + } } - imap_session.expunge().unwrap(); + match imap_session.expunge() { + Err(error) => warn!("Failed to expunge session: {error}"), + _ => {} + } } fn post_to_hookshot(hookshot_url: &str, email: &Email) -> reqwest::Result {