stack_db/
errors.rs

1//! Errors used in the `stack-db` crate
2
3use std::fmt::Display;
4
5/// Errors used in the `stack-db` crate
6#[derive(Debug)]
7pub enum Error {
8    /// An io error
9    IOError(std::io::Error),
10    /// An error that corrupts the database
11    DBCorrupt(Box<Error>),
12    /// If you try to write on a read-only layer
13    ReadOnly,
14    /// When the layer meta-data is invalid
15    InvalidLayer,
16    /// When there is an out of bounds read
17    OutOfBounds,
18    /// A custom error
19    Custom(String),
20}
21
22impl std::error::Error for Error {}
23impl Display for Error {
24    #[inline]
25    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26        write!(f, "{self:?}")
27    }
28}
29
30impl From<std::io::Error> for Error {
31    #[inline]
32    fn from(value: std::io::Error) -> Self {
33        Self::IOError(value)
34    }
35}