mirror of
https://github.com/chatmail/core.git
synced 2026-05-18 22:36:29 +03:00
refine processing of errors and result handling
This commit is contained in:
40
src/job.rs
40
src/job.rs
@@ -195,31 +195,29 @@ impl Job {
|
|||||||
warn!(context, "SMTP failed to send: {}", err);
|
warn!(context, "SMTP failed to send: {}", err);
|
||||||
self.pending_error = Some(err.to_string());
|
self.pending_error = Some(err.to_string());
|
||||||
|
|
||||||
// if the connection was successfully used more than 60
|
let res = match err {
|
||||||
// seconds ago, try an immediate reconnect.
|
|
||||||
let mut res = Status::RetryLater;
|
|
||||||
if let Some(secs) = smtp.secs_since_last_success() {
|
|
||||||
if secs > 60 {
|
|
||||||
info!(
|
|
||||||
context,
|
|
||||||
"SMTP connection was stale, triggering immediate reconnect"
|
|
||||||
);
|
|
||||||
res = Status::RetryNow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
match err {
|
|
||||||
async_smtp::smtp::error::Error::Permanent(_) => {
|
async_smtp::smtp::error::Error::Permanent(_) => {
|
||||||
res = Status::Finished(Err(format_err!("Permanent SMTP error: {}", err)))
|
Status::Finished(Err(format_err!("Permanent SMTP error: {}", err)))
|
||||||
}
|
}
|
||||||
async_smtp::smtp::error::Error::Transient(_) => {
|
async_smtp::smtp::error::Error::Transient(_) => {
|
||||||
// We got a 4xx response from SMTP server.
|
// We got a transient 4xx response from SMTP server.
|
||||||
// Do not retry right now, wait until the error resolves on the server
|
// Give some time until the server-side error maybe goes away.
|
||||||
// side.
|
Status::RetryLater
|
||||||
res = Status::RetryLater;
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {
|
||||||
}
|
// if the connection was successfully used more than 60
|
||||||
|
// seconds ago, try an immediate reconnect.
|
||||||
|
let mut res2 = Status::RetryLater;
|
||||||
|
if let Some(secs) = smtp.secs_since_last_success() {
|
||||||
|
if secs > 60 {
|
||||||
|
info!(context, "stale connection? triggering reconnect");
|
||||||
|
res2 = Status::RetryNow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res2
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// this clears last_success info
|
// this clears last_success info
|
||||||
smtp.disconnect();
|
smtp.disconnect();
|
||||||
|
|||||||
Reference in New Issue
Block a user