AppFlowy/rust-lib/flowy-user/src/errors.rs

24 lines
666 B
Rust
Raw Normal View History

2021-07-09 15:31:44 +00:00
use flowy_database::DataBaseError;
use std::sync::PoisonError;
#[derive(Debug)]
pub enum UserError {
2021-07-09 15:31:44 +00:00
DBInit(String),
DBNotInit,
UserNotLogin,
DBConnection(String),
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)) }
}
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)) }
}