graus_db/
error.rs

1use std::io;
2use std::string::FromUtf8Error;
3use thiserror::Error;
4
5/// Error type for GrausDb.
6#[derive(Error, Debug)]
7pub enum GrausError {
8    /// IO Error
9    #[error("GrausDb IO error")]
10    Io(#[from] io::Error),
11    /// Removing non-existent key error.
12    #[error("Key not found")]
13    KeyNotFound,
14    /// Serialization or deserialization error.
15    #[error("{0}")]
16    Serde(#[from] serde_json::Error),
17    /// Unexpected command type error.
18    /// It indicated a corrupted log or a program bug.
19    #[error("Unexpected command type")]
20    UnexpectedCommandType,
21    /// Key or value is invalid UTF-8 sequence
22    #[error("UTF-8 error: {0}")]
23    Utf8(#[from] FromUtf8Error),
24    /// Error with a string message
25    #[error("{0}")]
26    StringError(String),
27    /// Predicate passed to update_if was not satisfied.
28    #[error("Predicate not satisfied")]
29    PredicateNotSatisfied,
30}
31
32/// Result type for GrausDb.
33pub type Result<T> = std::result::Result<T, GrausError>;