#[non_exhaustive]pub enum Error {
UnprefixedIdentifier {
given: String,
},
InvalidIdentifier {
given: String,
why: &'static str,
},
InvalidOci {
given: String,
why: &'static str,
},
NoSuchOperation {
message: String,
},
Api {
status: u16,
body: String,
},
RateLimited {
attempts: u32,
},
Malformed {
what: &'static str,
source: Error,
},
ReqWest {
reqwest: Error,
},
Config {
msg: String,
},
}Expand description
Everything that can go wrong talking to OpenCitations.
Note what is not here: an identifier OpenCitations holds nothing about is
not an error. Both apis answer such a request with 200 and an empty list,
so a lookup that found nothing comes back as an empty Vec and a count of
zero. See Error::NoSuchOperation for the case that does fail.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnprefixedIdentifier
an identifier that is not scheme:value
OpenCitations addresses everything by a prefixed identifier – a bare
10.1016/j.marpol.2021.104855 means nothing to it, doi: in front of
it does. The prefix is required here rather than guessed at, because a
guess that picks the wrong scheme is answered with an empty list and
reads exactly like a work nobody has cited.
InvalidIdentifier
an identifier whose scheme or value is empty, e.g. doi: or :10.1016
InvalidOci
a string that is not an Open Citation Identifier
An OCI is the two OMIDs of the citing and cited work joined by a -,
e.g. 06024047477-06220256775.
NoSuchOperation
OpenCitations answered a route it does not serve
Answered with a 404 and a plain-text body rather than json, which is
what an identifier it could not even parse produces – citations/foo
rather than citations/doi:foo.
Api
OpenCitations refused the request
The body is passed through as it arrived, because it is sometimes json and sometimes plain text and neither shape is documented.
RateLimited
OpenCitations kept answering 429 until the retry budget ran out
The client paces itself well inside the documented 180 requests a
minute, so this normally means requests are also being made from
somewhere else on the same address – another process, or another
OpenCitations built separately rather than
cloned.
Malformed
a response this crate could not read
Every field of both apis arrives as a string, including the ones that are plainly numbers and dates, so this is where an unannounced change of shape surfaces.
Fields
ReqWest
an error that occurred while operating with reqwest
Config
the client could not be built
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()