nostrdb-rs

nostrdb in rust!
git clone git://jb55.com/nostrdb-rs
Log | Files | Refs | Submodules | README | LICENSE

error.rs (1157B)


      1 use thiserror::Error;
      2 
      3 /// Main error type
      4 #[derive(Debug, Error)]
      5 pub enum Error {
      6     #[error("Database open failed")]
      7     DbOpenFailed,
      8 
      9     #[error("Not found")]
     10     NotFound,
     11 
     12     #[error("Decode error")]
     13     DecodeError,
     14 
     15     #[error("Query failed")]
     16     QueryError,
     17 
     18     #[error("Note process failed")]
     19     NoteProcessFailed,
     20 
     21     #[error("Transaction failed")]
     22     TransactionFailed,
     23 
     24     #[error("Subscription failed")]
     25     SubscriptionError,
     26 
     27     #[error("Buffer overflow")]
     28     BufferOverflow,
     29 
     30     #[error("CString failed")]
     31     CString(#[from] std::ffi::NulError),
     32 
     33     #[error("Filter error: {0}")]
     34     Filter(#[from] FilterError),
     35 
     36     #[error("IO error: {0}")]
     37     IO(#[from] std::io::Error),
     38 }
     39 
     40 /// Filter-specific error type
     41 #[derive(Debug, Error, Eq, PartialEq)]
     42 pub enum FilterError {
     43     #[error("Field already exists")]
     44     FieldAlreadyExists,
     45 
     46     #[error("Field already started")]
     47     FieldAlreadyStarted,
     48 }
     49 
     50 impl FilterError {
     51     pub fn already_exists() -> Error {
     52         Error::Filter(FilterError::FieldAlreadyExists)
     53     }
     54 
     55     pub fn already_started() -> Error {
     56         Error::Filter(FilterError::FieldAlreadyStarted)
     57     }
     58 }