Skip to main content

engram/
error.rs

1use thiserror::Error;
2
3/// Failures returned by Engram operations.
4#[derive(Debug, Error)]
5pub enum Error {
6    #[error("failed to serialize cached value: {0}")]
7    Serialize(#[source] bincode::Error),
8    #[error("failed to deserialize cached value: {0}")]
9    Deserialize(#[source] bincode::Error),
10    #[error("SQLite operation failed: {0}")]
11    Sqlite(#[from] sqlx::Error),
12    #[error("Zstandard operation failed: {0}")]
13    Compression(#[source] std::io::Error),
14    #[error("cached value for key `{key}` has type `{actual}`, not requested type `{requested}`")]
15    TypeMismatch {
16        key: String,
17        requested: String,
18        actual: String,
19    },
20    #[error("background compression task failed: {0}")]
21    BackgroundTask(#[from] tokio::task::JoinError),
22}
23
24pub type Result<T> = std::result::Result<T, Error>;