use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("{0} is not set; export a Linear API key (https://linear.app/settings/api)")]
MissingToken(&'static str),
#[error("Linear rejected the API key (HTTP {0})")]
Unauthorized(u16),
#[error("Linear API error: {}", .0.join("; "))]
Api(Vec<String>),
#[error("not found: {0}")]
NotFound(String),
#[error("unexpected response from Linear: {0}")]
Unexpected(String),
#[error(
"{remote_key} changed in Linear since the last sync \
(remote {remote}, ours {ours}); re-import first, or pass --force"
)]
StaleWrite {
remote_key: String,
remote: String,
ours: String,
},
#[error("config: {0}")]
Config(String),
#[error("HTTP transport: {0}")]
Http(String),
#[error(transparent)]
Core(#[from] cliban_core::Error),
#[error(transparent)]
Sqlite(#[from] rusqlite::Error),
#[error(transparent)]
Json(#[from] serde_json::Error),
}
impl From<reqwest::Error> for Error {
fn from(e: reqwest::Error) -> Self {
Error::Http(e.to_string())
}
}
pub type Result<T> = std::result::Result<T, Error>;