Files
mtgc/crates/mtgc-core/src/error.rs

33 lines
599 B
Rust
Raw Normal View History

//! Core error type.
use thiserror::Error;
#[derive(Debug, Error)]
pub enum CoreError {
#[error(transparent)]
Sqlite(#[from] rusqlite::Error),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("http error: {0}")]
Http(String),
#[error("json error: {0}")]
Json(#[from] serde_json::Error),
#[error("cancelled")]
Cancelled,
#[error("{0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, CoreError>;
impl From<ureq::Error> for CoreError {
fn from(e: ureq::Error) -> Self {
CoreError::Http(e.to_string())
}
}