pub enum OpenAlexError {
Http(Error),
Json(Error),
Api {
status: u16,
message: String,
},
}Expand description
Errors returned by OpenAlexClient methods.
§Variants
Http— network or connection failure (wrapsreqwest::Error)Json— response body could not be deserialized (wrapsserde_json::Error)Api— the OpenAlex API returned a non-success HTTP status code (e.g. 404 for unknown entity, 403 for forbidden, 500 for server error)
§Example
use papers_openalex::{OpenAlexClient, GetParams, OpenAlexError};
let client = OpenAlexClient::new();
match client.get_work("nonexistent", &GetParams::default()).await {
Ok(work) => println!("Found: {}", work.id),
Err(OpenAlexError::Api { status, message }) => {
eprintln!("API error {status}: {message}");
}
Err(e) => eprintln!("Other error: {e}"),
}Variants§
Http(Error)
Network or connection error from reqwest.
Json(Error)
Failed to deserialize the JSON response body.
Api
The API returned a non-success HTTP status code.
status is the HTTP status code (e.g. 404, 403, 500) and message
contains the response body text.
Trait Implementations§
Source§impl Debug for OpenAlexError
impl Debug for OpenAlexError
Source§impl Display for OpenAlexError
impl Display for OpenAlexError
Source§impl Error for OpenAlexError
impl Error for OpenAlexError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<Error> for OpenAlexError
impl From<Error> for OpenAlexError
Source§fn from(source: Error) -> OpenAlexError
fn from(source: Error) -> OpenAlexError
Converts to this type from the input type.
Source§impl From<Error> for OpenAlexError
impl From<Error> for OpenAlexError
Source§fn from(source: Error) -> OpenAlexError
fn from(source: Error) -> OpenAlexError
Converts to this type from the input type.
Source§impl From<OpenAlexError> for FilterError
impl From<OpenAlexError> for FilterError
Source§fn from(source: OpenAlexError) -> Self
fn from(source: OpenAlexError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for OpenAlexError
impl !RefUnwindSafe for OpenAlexError
impl Send for OpenAlexError
impl Sync for OpenAlexError
impl Unpin for OpenAlexError
impl UnsafeUnpin for OpenAlexError
impl !UnwindSafe for OpenAlexError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.