#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[error("Typst error: {0}")]
Typst(String),
#[error("AnkiConnect error: {0}")]
AnkiConnect(String),
#[error("Cache error: {0}")]
Cache(String),
#[error("{0}")]
Custom(String),
}
pub type Result<T> = std::result::Result<T, Error>;
impl Error {
pub fn custom<S: Into<String>>(message: S) -> Self {
Error::Custom(message.into())
}
pub fn typst<S: Into<String>>(message: S) -> Self {
Error::Typst(message.into())
}
pub fn anki_connect<S: Into<String>>(message: S) -> Self {
Error::AnkiConnect(message.into())
}
pub fn cache<S: Into<String>>(message: S) -> Self {
Error::Cache(message.into())
}
}