use std::result;
use thiserror::Error as ThisError;
pub type Result<T> = result::Result<T, Error>;
#[derive(Debug, ThisError)]
#[non_exhaustive]
pub enum Error {
#[error(
"`{given}` is not a `scheme:value` identifier; write it as `doi:{given}` or `pmid:{given}`"
)]
UnprefixedIdentifier {
given: String,
},
#[error("`{given}` is not an identifier: {why}")]
InvalidIdentifier {
given: String,
why: &'static str,
},
#[error("`{given}` is not an open citation identifier: {why}")]
InvalidOci {
given: String,
why: &'static str,
},
#[error("opencitations serves no such operation: {message}")]
NoSuchOperation {
message: String,
},
#[error("opencitations answered {status}: {body}")]
Api {
status: u16,
body: String,
},
#[error("opencitations rate limited the request; gave up after {attempts} attempts")]
RateLimited {
attempts: u32,
},
#[error("could not read the {what} in opencitations' answer: {source}")]
Malformed {
what: &'static str,
source: serde_json::Error,
},
#[error(transparent)]
ReqWest {
#[from]
reqwest: reqwest::Error,
},
#[error("{msg}")]
Config {
msg: String,
},
}