HomeDisk/types/src/errors/database.rs

29 lines
608 B
Rust
Raw Normal View History

2022-06-08 19:16:12 +00:00
/// Database Error
2022-06-07 20:36:26 +00:00
#[derive(Debug, thiserror::Error)]
pub enum Error {
2022-06-11 08:19:47 +00:00
/// User not found!
/// Username or Password incorrect.
2022-06-07 20:36:26 +00:00
#[error("user not found")]
UserNotFound,
2022-06-08 19:16:12 +00:00
/// sqlx::Error
2022-06-07 20:36:26 +00:00
#[error("sqlx error - {0}")]
SQLx(sqlx::Error),
2022-06-08 19:16:12 +00:00
/// std::io::Error
2022-06-07 20:36:26 +00:00
#[error("std::io error - {0}")]
2022-06-08 19:16:12 +00:00
StdIo(std::io::Error),
}
2022-06-08 17:08:06 +00:00
/// sqlx::Error
impl From<sqlx::Error> for Error {
fn from(err: sqlx::Error) -> Self {
Error::SQLx(err)
}
}
2022-06-08 17:08:06 +00:00
/// std::io::Error
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Self {
2022-06-08 19:16:12 +00:00
Error::StdIo(err)
}
}