mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
Remove ContextError type
Using anyhow instead.
This commit is contained in:
@@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant, SystemTime};
|
||||
|
||||
use anyhow::{ensure, Result};
|
||||
use anyhow::{bail, ensure, Result};
|
||||
use async_channel::{self as channel, Receiver, Sender};
|
||||
use ratelimit::Ratelimit;
|
||||
use tokio::sync::{Mutex, RwLock};
|
||||
@@ -149,26 +149,17 @@ impl ContextBuilder {
|
||||
}
|
||||
|
||||
/// Opens the [`Context`].
|
||||
pub async fn open(self) -> Result<Context, ContextError> {
|
||||
pub async fn open(self) -> Result<Context> {
|
||||
let context =
|
||||
Context::new_closed(&self.dbfile, self.id, self.events, self.stock_strings).await?;
|
||||
let password = self.password.unwrap_or_default();
|
||||
match context.open(password).await? {
|
||||
true => Ok(context),
|
||||
false => Err(ContextError::DatabaseEncrypted),
|
||||
false => bail!("database could not be decrypted, incorrect or missing password"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ContextError {
|
||||
#[error("database could not be decrypted, incorrect or missing password")]
|
||||
DatabaseEncrypted,
|
||||
#[error("failed to open context")]
|
||||
Other(#[from] anyhow::Error),
|
||||
}
|
||||
|
||||
/// The context for a single DeltaChat account.
|
||||
///
|
||||
/// This contains all the state for a single DeltaChat account, including background tasks
|
||||
|
||||
Reference in New Issue
Block a user