easy_sqlite/entities/
errors.rs

1use std::sync::PoisonError;
2
3#[derive(Debug, PartialEq, Eq, Clone)]
4pub enum DbError {
5    CanNotConnect(String),
6    CanNotInitTable(&'static str, String),
7    NotFound(Option<String>),
8    MutexError,
9    DeserializationError(String),
10    Other(String),
11}
12
13pub type DbResult<T> = Result<T, DbError>;
14
15impl<T> From<PoisonError<T>> for DbError {
16    fn from(_: PoisonError<T>) -> Self {
17        DbError::MutexError
18    }
19}
20
21impl From<rusqlite::Error> for DbError {
22    fn from(src: rusqlite::Error) -> Self {
23        DbError::Other(src.to_string())
24    }
25}