error.rs (1084B)
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("Filter error: {0}")] 31 Filter(#[from] FilterError), 32 33 #[error("IO error: {0}")] 34 IO(#[from] std::io::Error), 35 } 36 37 /// Filter-specific error type 38 #[derive(Debug, Error, Eq, PartialEq)] 39 pub enum FilterError { 40 #[error("Field already exists")] 41 FieldAlreadyExists, 42 43 #[error("Field already started")] 44 FieldAlreadyStarted, 45 } 46 47 impl FilterError { 48 pub fn already_exists() -> Error { 49 Error::Filter(FilterError::FieldAlreadyExists) 50 } 51 52 pub fn already_started() -> Error { 53 Error::Filter(FilterError::FieldAlreadyStarted) 54 } 55 }