From 9ba1f290ad161f0ef9d322c389feeeba0acaa619 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Sun, 24 Feb 2019 17:45:47 -0500 Subject: [PATCH] Don't hide errors --- src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 945e6fa..7b87fd2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,9 +58,10 @@ struct Connection { impl Connection { pub fn handle(mut self, account: usize, mut tx: mpsc::Sender<(usize, usize)>) { loop { - if let Err(_) = self.check(account, &mut tx) { + if let Err(e) = self.check(account, &mut tx) { // the connection has failed for some reason // try to log out (we probably can't) + eprintln!("connection to {} failed: {:?}", self.account.name, e); self.socket.logout().is_err(); break; } @@ -69,7 +70,7 @@ impl Connection { // try to reconnect let mut wait = 1; for _ in 0..5 { - println!( + eprintln!( "connection to {} lost; trying to reconnect...", self.account.name ); @@ -78,10 +79,10 @@ impl Connection { println!("{} connection reestablished", self.account.name); return c.handle(account, tx); } - Err(imap::error::Error::Io(_)) => { + Err(e) => { + eprintln!("failed to connect to {}: {:?}", self.account.name, e); thread::sleep(Duration::from_secs(wait)); } - Err(_) => break, } wait *= 2;