Error handling refactoring

- Replace .ok_or_else() and .map_err() with anyhow::Context where possible.
- Use .context() to check Option for None when it's an error
- Resultify Chatlist.get_chat_id()
- Add useful .context() to some errors
- IMAP error handling cleanup
This commit is contained in:
link2xt
2022-01-05 01:51:11 +00:00
parent 29c58efeb3
commit bfa641cea8
24 changed files with 252 additions and 283 deletions

View File

@@ -196,9 +196,13 @@ impl Imap {
// we are connected, and the folder is selected
info!(context, "Downloading message {}/{} fully...", folder, uid);
let (last_uid, _received) = self
let (last_uid, _received) = match self
.fetch_many_msgs(context, folder, vec![uid], false, false)
.await;
.await
{
Ok(res) => res,
Err(_) => return ImapActionResult::Failed,
};
if last_uid.is_none() {
ImapActionResult::Failed
} else {