Skip to main content

koit_toml/
error.rs

1use thiserror::Error;
2
3/// The error variants Koit can return.
4///
5/// The concrete source error types are the associated errors types
6/// [`Format::Error`](crate::format::Format::Error) and [`Backend::Error`](crate::backend::Backend::Error).
7#[derive(Debug, Error)]
8pub enum KoitError {
9    /// Data failed to be encoded by the formatter.
10    #[error("the database failed to serialize")]
11    ToFormat(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
12    /// Data failed to be decoded by the formatter.
13    #[error("the database failed to deserialize")]
14    FromFormat(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
15    /// The backend failed to read bytes.
16    #[error("failed to read from the backend")]
17    BackendRead(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
18    /// The backend failed to write bytes.
19    #[error("failed to write to the backend")]
20    BackendWrite(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
21    /// The backend failed to be created.
22    #[error("failed to create backend")]
23    BackendCreation(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
24}