Don't hide errors
This commit is contained in:
parent
874c5a609f
commit
9ba1f290ad
|
@ -58,9 +58,10 @@ struct Connection<T: Read + Write> {
|
||||||
impl<T: Read + Write + imap::extensions::idle::SetReadTimeout> Connection<T> {
|
impl<T: Read + Write + imap::extensions::idle::SetReadTimeout> Connection<T> {
|
||||||
pub fn handle(mut self, account: usize, mut tx: mpsc::Sender<(usize, usize)>) {
|
pub fn handle(mut self, account: usize, mut tx: mpsc::Sender<(usize, usize)>) {
|
||||||
loop {
|
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
|
// the connection has failed for some reason
|
||||||
// try to log out (we probably can't)
|
// try to log out (we probably can't)
|
||||||
|
eprintln!("connection to {} failed: {:?}", self.account.name, e);
|
||||||
self.socket.logout().is_err();
|
self.socket.logout().is_err();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +70,7 @@ impl<T: Read + Write + imap::extensions::idle::SetReadTimeout> Connection<T> {
|
||||||
// try to reconnect
|
// try to reconnect
|
||||||
let mut wait = 1;
|
let mut wait = 1;
|
||||||
for _ in 0..5 {
|
for _ in 0..5 {
|
||||||
println!(
|
eprintln!(
|
||||||
"connection to {} lost; trying to reconnect...",
|
"connection to {} lost; trying to reconnect...",
|
||||||
self.account.name
|
self.account.name
|
||||||
);
|
);
|
||||||
|
@ -78,10 +79,10 @@ impl<T: Read + Write + imap::extensions::idle::SetReadTimeout> Connection<T> {
|
||||||
println!("{} connection reestablished", self.account.name);
|
println!("{} connection reestablished", self.account.name);
|
||||||
return c.handle(account, tx);
|
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));
|
thread::sleep(Duration::from_secs(wait));
|
||||||
}
|
}
|
||||||
Err(_) => break,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wait *= 2;
|
wait *= 2;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user