30 lines
557 B
Rust
30 lines
557 B
Rust
|
|
//! 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("{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())
|
||
|
|
}
|
||
|
|
}
|