shorterdb/
errors.rs

1// use serde_json;
2use std::io;
3use thiserror::Error;
4
5/// Error type for kvs.
6#[derive(Error, Debug)]
7pub enum ShortDBErrors {
8    /// IO error.
9    #[error("{0}")]
10    Io(#[from] io::Error),
11    /// Serialization or deserialization error.
12    // #[error("{0}")]
13    // Serde(#[from] serde_json::Error),
14    /// Removing non-existent key error.
15    #[error("Key not found")]
16    KeyNotFound,
17    /// Unexpected command type error.
18    /// It indicates a corrupted log or a program bug.
19    #[error("Unexpected command type")]
20    UnexpectedCommandType,
21    //value is not set, it is given when we try get after set
22    #[error("Value not set")]
23    ValueNotSet,
24    #[error("We need to flush to sst, Max size for Memtable reached")]
25    FlushNeededFromMemTable,
26}
27
28/// Result type for kvs.
29pub type Result<T> = std::result::Result<T, ShortDBErrors>;