2021-07-09 15:31:44 +00:00
|
|
|
use flowy_database::DataBaseError;
|
2021-07-09 08:34:50 +00:00
|
|
|
use std::sync::PoisonError;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum UserError {
|
2021-07-09 15:31:44 +00:00
|
|
|
DBInit(String),
|
|
|
|
DBNotInit,
|
|
|
|
UserNotLogin,
|
|
|
|
DBConnection(String),
|
2021-07-09 08:34:50 +00:00
|
|
|
PoisonError(String),
|
|
|
|
}
|
|
|
|
|
2021-07-09 15:31:44 +00:00
|
|
|
impl std::convert::From<DataBaseError> for UserError {
|
|
|
|
fn from(error: DataBaseError) -> Self { UserError::DBInit(format!("{:?}", error)) }
|
2021-07-09 08:34:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> std::convert::From<PoisonError<T>> for UserError {
|
|
|
|
fn from(error: PoisonError<T>) -> Self { UserError::PoisonError(format!("{:?}", error)) }
|
|
|
|
}
|
2021-07-09 15:31:44 +00:00
|
|
|
|
|
|
|
impl std::convert::From<flowy_sqlite::Error> for UserError {
|
|
|
|
fn from(e: flowy_sqlite::Error) -> Self { UserError::DBConnection(format!("{:?}", e)) }
|
|
|
|
}
|