mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
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:
@@ -1,6 +1,6 @@
|
||||
//! Migrations module.
|
||||
|
||||
use anyhow::Result;
|
||||
use anyhow::{Context as _, Result};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::constants::ShowEmails;
|
||||
@@ -19,7 +19,11 @@ pub async fn run(context: &Context, sql: &Sql) -> Result<(bool, bool, bool, bool
|
||||
let mut exists_before_update = false;
|
||||
let mut dbversion_before_update = DBVERSION;
|
||||
|
||||
if !sql.table_exists("config").await? {
|
||||
if !sql
|
||||
.table_exists("config")
|
||||
.await
|
||||
.context("failed to check if config table exists")?
|
||||
{
|
||||
info!(context, "First time init: creating tables",);
|
||||
sql.transaction(move |transaction| {
|
||||
transaction.execute_batch(TABLES)?;
|
||||
@@ -572,7 +576,8 @@ impl Sql {
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.await?;
|
||||
.await
|
||||
.with_context(|| format!("execute_migration failed for version {}", version))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user