mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-02-13 02:13:06 +00:00
* feat: shared storage crate * chore: remove backup codes * chore: remove feature gates * chore: clean out of order demo * chore: refactor create session * chore: shorten error name * chore: clean errors * chore: remove table exist check * chore: remove unused traits * chore: remove unused functions. * chore: use tempfile for examples
36 lines
847 B
Rust
36 lines
847 B
Rust
use thiserror::Error;
|
|
|
|
/// Common storage errors.
|
|
#[derive(Debug, Error)]
|
|
pub enum StorageError {
|
|
/// Database error (wraps rusqlite::Error when sqlite feature is enabled).
|
|
#[error("database error: {0}")]
|
|
Database(String),
|
|
|
|
/// Record not found.
|
|
#[error("not found: {0}")]
|
|
NotFound(String),
|
|
|
|
/// Serialization error.
|
|
#[error("serialization error: {0}")]
|
|
Serialization(String),
|
|
|
|
/// Deserialization error.
|
|
#[error("deserialization error: {0}")]
|
|
Deserialization(String),
|
|
|
|
/// Schema migration error.
|
|
#[error("migration error: {0}")]
|
|
Migration(String),
|
|
|
|
/// Transaction error.
|
|
#[error("transaction error: {0}")]
|
|
Transaction(String),
|
|
}
|
|
|
|
impl From<rusqlite::Error> for StorageError {
|
|
fn from(e: rusqlite::Error) -> Self {
|
|
StorageError::Database(e.to_string())
|
|
}
|
|
}
|