2022-04-16 22:09:23 +00:00
|
|
|
use std::fmt;
|
|
|
|
|
|
|
|
use crate::crypto;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Error {
|
|
|
|
Crypto(crypto::Error),
|
2022-04-19 11:05:47 +00:00
|
|
|
SQLx(sqlx::Error),
|
2022-04-16 22:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<crypto::Error> for Error {
|
|
|
|
fn from(err: crypto::Error) -> Self {
|
|
|
|
Error::Crypto(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-19 11:05:47 +00:00
|
|
|
impl From<sqlx::Error> for Error {
|
|
|
|
fn from(err: sqlx::Error) -> Self {
|
|
|
|
Error::SQLx(err)
|
2022-04-16 22:09:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl fmt::Display for Error {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
match self {
|
|
|
|
Error::Crypto(err) => write!(f, "crypto error: {}", err),
|
2022-04-19 11:05:47 +00:00
|
|
|
Error::SQLx(err) => write!(f, "sqlx error: {}", err),
|
2022-04-16 22:09:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|