error.rs (650B)
1 use std::fmt; 2 3 #[derive(Debug)] 4 pub enum Error { 5 Connection, 6 CreateTable, 7 AccountRetrieval, 8 } 9 10 impl std::error::Error for Error {} 11 12 impl fmt::Display for Error { 13 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 14 match self { 15 Error::Connection => write!(f, "Database connection error"), 16 Error::CreateTable => write!(f, "Could not create Sql table"), 17 Error::AccountRetrieval => write!(f, "Could not create retrieve account"), 18 } 19 } 20 } 21 22 #[cfg(feature = "sqlite")] 23 impl From<rusqlite::Error> for Error { 24 fn from(_: rusqlite::Error) -> Self { 25 Error::Connection 26 } 27 }