use std::{io, num::TryFromIntError, time::SystemTimeError};
use chrono::ParseError;
use indicatif::style::TemplateError;
use reqwest::StatusCode;
use crate::db::DBError;
pub type MLE<T> = Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("io: {source}")]
Io {
#[from]
source: io::Error,
},
#[error("tryfromint: {source}")]
TryFromInt {
#[from]
source: TryFromIntError,
},
#[error("serde_json: {source}")]
Json {
#[from]
source: serde_json::Error,
},
#[error("reqwest: {source}")]
Reqwest {
#[from]
source: reqwest::Error,
},
#[error("chrono parse error: {source}")]
ChronoParse {
#[from]
source: ParseError,
},
#[error("config: {source}")]
Config {
#[from]
source: config::ConfigError,
},
#[error("indicatif template: {source}")]
IndicatifTemplate {
#[from]
source: TemplateError,
},
#[error("toml: {source}")]
TomlSer {
#[from]
source: toml::ser::Error,
},
#[error("toml: {source}")]
TomlDeser {
#[from]
source: toml::de::Error,
},
#[error("systemtime: {source}")]
Systemtime {
#[from]
source: SystemTimeError,
},
#[error("conversion: {source}")]
Conversion {
#[from]
source: ConversionError,
},
#[error("Request didn't return 200 OK ({0})")]
RequestNotOK(StatusCode),
#[error("ModError ({0})")]
ModError(String),
#[error("No file extension where one should be")]
NoFileExtension,
#[error("Desired path not found")]
PathNotFound,
#[error("Desired system directory {0} not found")]
SysDirNotFound(String),
#[error("No requested Minecraft version found")]
MinecraftVersionNotFound,
#[error("Mod already added")]
ModAlreadyOnList,
#[error("No versions are applicable for the current scope")]
NoCurrentVersion,
#[error("The version does not know if it's locked or not")]
VersionSetNotSet,
#[error("No download for the current id found")]
NoDownload,
#[error("No ProjectInfo found / no id given")]
NoProjectInfo,
#[error("The requested List was not found")]
ListNotFound,
#[error("No download folder given")]
NoDownloadFolder,
#[error("db: {source}")]
DB {
#[from]
source: DBError,
},
}
#[derive(Debug, thiserror::Error)]
pub enum ConversionError {
#[error("couldn't convert to Modloader from: {0}")]
Modloader(String),
#[error("Path couldn't be converted to string")]
InvalidPath,
}