feat: added basic user management
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
UserCreate(String),
|
||||
#[cfg(feature = "ssr")]
|
||||
Sqlx(sqlx::Error),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Error::UserCreate(err) => {
|
||||
write!(f, "user create error: {err}")
|
||||
}
|
||||
#[cfg(feature = "ssr")]
|
||||
Error::Sqlx(err) => {
|
||||
write!(f, "sqlx error: {err:?}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
#[cfg(feature = "ssr")]
|
||||
Error::Sqlx(err) => Some(err),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
impl From<sqlx::Error> for Error {
|
||||
fn from(err: sqlx::Error) -> Self {
|
||||
Self::Sqlx(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user