140 lines
4.1 KiB
Rust
140 lines
4.1 KiB
Rust
use crate::discord::voices::VoiceError;
|
|
use crate::image_manipulation::ModifyImageArgError;
|
|
use crate::models::gogurt_reserves::GogurtError;
|
|
use crate::models::improvements::ImprovementError;
|
|
use crate::user;
|
|
use magick_rust::MagickError;
|
|
use serde::ser::StdError;
|
|
use std::fmt::{Display, Formatter};
|
|
|
|
#[derive(Debug)]
|
|
#[allow(clippy::enum_variant_names)]
|
|
#[allow(dead_code)]
|
|
pub enum Error {
|
|
ConfigError(config::ConfigError),
|
|
SerenityError(Box<poise::serenity_prelude::Error>),
|
|
TeraError(tera::Error),
|
|
NoAlbumFound,
|
|
UserError(user::UserError),
|
|
DbError(j_db::error::JDbError),
|
|
ReqwestError(reqwest::Error),
|
|
ParseFailure,
|
|
RaasError(String),
|
|
MagickError(magick_rust::MagickError),
|
|
CommandError(String),
|
|
IoError(std::io::Error),
|
|
VoiceError(Box<VoiceError>),
|
|
CTAError(cta_api::Error),
|
|
NoImageFound,
|
|
PipelineArgumentError(ModifyImageArgError),
|
|
NoRandomFound,
|
|
GogurtError(GogurtError),
|
|
ImprovementError(ImprovementError),
|
|
}
|
|
|
|
impl StdError for Error {}
|
|
|
|
impl From<config::ConfigError> for Error {
|
|
fn from(e: config::ConfigError) -> Self {
|
|
Self::ConfigError(e)
|
|
}
|
|
}
|
|
|
|
impl From<poise::serenity_prelude::Error> for Error {
|
|
fn from(err: poise::serenity_prelude::Error) -> Self {
|
|
Self::SerenityError(Box::new(err))
|
|
}
|
|
}
|
|
|
|
impl From<tera::Error> for Error {
|
|
fn from(err: tera::Error) -> Self {
|
|
Self::TeraError(err)
|
|
}
|
|
}
|
|
|
|
impl From<user::UserError> for Error {
|
|
fn from(err: user::UserError) -> Self {
|
|
Self::UserError(err)
|
|
}
|
|
}
|
|
|
|
impl From<j_db::error::JDbError> for Error {
|
|
fn from(err: j_db::error::JDbError) -> Self {
|
|
Self::DbError(err)
|
|
}
|
|
}
|
|
|
|
impl From<reqwest::Error> for Error {
|
|
fn from(err: reqwest::Error) -> Self {
|
|
Self::ReqwestError(err)
|
|
}
|
|
}
|
|
|
|
impl From<magick_rust::MagickError> for Error {
|
|
fn from(value: MagickError) -> Self {
|
|
Self::MagickError(value)
|
|
}
|
|
}
|
|
|
|
impl From<std::io::Error> for Error {
|
|
fn from(value: std::io::Error) -> Self {
|
|
Self::IoError(value)
|
|
}
|
|
}
|
|
|
|
impl From<VoiceError> for Error {
|
|
fn from(value: VoiceError) -> Self {
|
|
Self::VoiceError(Box::new(value))
|
|
}
|
|
}
|
|
|
|
impl From<cta_api::Error> for Error {
|
|
fn from(value: cta_api::Error) -> Self {
|
|
Self::CTAError(value)
|
|
}
|
|
}
|
|
|
|
impl From<ModifyImageArgError> for Error {
|
|
fn from(value: ModifyImageArgError) -> Self {
|
|
Self::PipelineArgumentError(value)
|
|
}
|
|
}
|
|
|
|
impl From<GogurtError> for Error {
|
|
fn from(value: GogurtError) -> Self {
|
|
Self::GogurtError(value)
|
|
}
|
|
}
|
|
|
|
impl From<ImprovementError> for Error {
|
|
fn from(value: ImprovementError) -> Self {
|
|
Self::ImprovementError(value)
|
|
}
|
|
}
|
|
|
|
impl Display for Error {
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
Error::ConfigError(e) => write!(f, "Config error: {e}"),
|
|
Error::SerenityError(e) => write!(f, "Discord error: {e}"),
|
|
Error::TeraError(e) => write!(f, "Tera error: {e}"),
|
|
Error::NoAlbumFound => write!(f, "No album found"),
|
|
Error::UserError(e) => write!(f, "User error: {e}"),
|
|
Error::DbError(e) => write!(f, "DB error: {e}"),
|
|
Error::ReqwestError(e) => write!(f, "Reqwest Error: {e}"),
|
|
Error::ParseFailure => write!(f, "Failed to parse something or other"),
|
|
Error::RaasError(msg) => write!(f, "Got error from RaaS: {msg}"),
|
|
Error::MagickError(err) => write!(f, "ImageMagick error: {err}"),
|
|
Error::CommandError(err_msg) => write!(f, "{err_msg}"),
|
|
Error::IoError(err) => write!(f, "IO Error: {err}"),
|
|
Error::VoiceError(err) => write!(f, "Voice error: {err}"),
|
|
Error::CTAError(err) => write!(f, "The CTA had an error, I'm shocked: {err}"),
|
|
Error::NoImageFound => write!(f, "Image not found"),
|
|
Error::PipelineArgumentError(err) => write!(f, "{err}"),
|
|
Error::NoRandomFound => write!(f, "No random found"),
|
|
Error::GogurtError(err) => write!(f, "{err}"),
|
|
Error::ImprovementError(err) => write!(f, "{err}"),
|
|
}
|
|
}
|
|
}
|