imap: add log entry on connection retry & failure

embed
Manos Pitsidianakis 2019-09-15 23:44:42 +03:00
parent 86f21fbe52
commit 080b8ae775
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 15 additions and 1 deletions

View File

@ -21,6 +21,7 @@
use crate::email::parser::BytesExt;
use crate::error::*;
use crate::logging::{LoggingLevel::*, *};
use std::io::Read;
use std::io::Write;
extern crate native_tls;
@ -98,6 +99,13 @@ impl ImapConnection {
std::mem::replace(&mut self.server_username, String::new());
let server_password =
std::mem::replace(&mut self.server_password, String::new());
log(
format!(
"IMAP connection to `{}` failed. Retrying one more time...",
&server_hostname
),
ERROR,
);
*self = ImapConnection::new_connection(
server_hostname,
server_username,
@ -107,7 +115,13 @@ impl ImapConnection {
.1;
connection_tries += 1;
}
Err(e) => return Err(MeliError::from(e)),
Err(e) => {
log(
format!("IMAP connection to `{}` failed.", &self.server_hostname),
FATAL,
);
return Err(MeliError::from(e));
}
}
}
Ok(())