mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +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::sync::Arc;
|
||||||
use std::time::{Duration, Instant, SystemTime};
|
use std::time::{Duration, Instant, SystemTime};
|
||||||
|
|
||||||
use anyhow::{ensure, Result};
|
use anyhow::{bail, ensure, Result};
|
||||||
use async_channel::{self as channel, Receiver, Sender};
|
use async_channel::{self as channel, Receiver, Sender};
|
||||||
use ratelimit::Ratelimit;
|
use ratelimit::Ratelimit;
|
||||||
use tokio::sync::{Mutex, RwLock};
|
use tokio::sync::{Mutex, RwLock};
|
||||||
@@ -149,26 +149,17 @@ impl ContextBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Opens the [`Context`].
|
/// Opens the [`Context`].
|
||||||
pub async fn open(self) -> Result<Context, ContextError> {
|
pub async fn open(self) -> Result<Context> {
|
||||||
let context =
|
let context =
|
||||||
Context::new_closed(&self.dbfile, self.id, self.events, self.stock_strings).await?;
|
Context::new_closed(&self.dbfile, self.id, self.events, self.stock_strings).await?;
|
||||||
let password = self.password.unwrap_or_default();
|
let password = self.password.unwrap_or_default();
|
||||||
match context.open(password).await? {
|
match context.open(password).await? {
|
||||||
true => Ok(context),
|
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.
|
/// The context for a single DeltaChat account.
|
||||||
///
|
///
|
||||||
/// This contains all the state for a single DeltaChat account, including background tasks
|
/// This contains all the state for a single DeltaChat account, including background tasks
|
||||||
|
|||||||
Reference in New Issue
Block a user