38 lines
907 B
Rust
38 lines
907 B
Rust
use crate::imgur::ImgurError;
|
|
use std::fmt::{Display, Formatter};
|
|
|
|
#[derive(Debug)]
|
|
pub enum Error {
|
|
ConfigError(config::ConfigError),
|
|
ImgurError(ImgurError),
|
|
SerenityError(serenity::Error),
|
|
}
|
|
|
|
impl From<config::ConfigError> for Error {
|
|
fn from(e: config::ConfigError) -> Self {
|
|
Self::ConfigError(e)
|
|
}
|
|
}
|
|
|
|
impl From<ImgurError> for Error {
|
|
fn from(e: ImgurError) -> Self {
|
|
Self::ImgurError(e)
|
|
}
|
|
}
|
|
|
|
impl From<serenity::Error> for Error {
|
|
fn from(err: serenity::Error) -> Self {
|
|
Self::SerenityError(err)
|
|
}
|
|
}
|
|
|
|
impl Display for Error {
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
Error::ConfigError(e) => write!(f, "Config error: {}", e),
|
|
Error::ImgurError(e) => write!(f, "Imgur error: {}", e),
|
|
Error::SerenityError(e) => write!(f, "Discord error: {}", e),
|
|
}
|
|
}
|
|
}
|