pub enum Error<E = ()> {
InvalidRequest(String),
CommunicationError(Error),
InvalidUpgrade(Error),
ErrorResponse(ResponseValue<E>),
ResponseBodyError(Error),
InvalidResponsePayload(Bytes, Error),
UnexpectedResponse(Response),
Custom(String),
}
Expand description
Error produced by generated client methods.
The type parameter may be a struct if there’s a single expected error type or an enum if there are multiple valid error types. It can be the unit type if there are no structured returns expected.
Variants§
InvalidRequest(String)
The request did not conform to API requirements.
CommunicationError(Error)
A server error either due to the data, or with the connection.
InvalidUpgrade(Error)
An expected response when upgrading connection.
ErrorResponse(ResponseValue<E>)
A documented, expected error response.
ResponseBodyError(Error)
Encountered an error reading the body for an expected response.
InvalidResponsePayload(Bytes, Error)
An expected response code whose deserialization failed.
UnexpectedResponse(Response)
A response not listed in the API description. This may represent a
success or failure response; check status().is_success()
.
Custom(String)
A custom error from a consumer-defined hook.
Implementations§
Source§impl<E> Error<E>
impl<E> Error<E>
Sourcepub fn status(&self) -> Option<StatusCode>
pub fn status(&self) -> Option<StatusCode>
Returns the status code, if the error was generated from a response.
Sourcepub fn into_untyped(self) -> Error
pub fn into_untyped(self) -> Error
Converts this error into one without a typed body.
This is useful for unified error handling with APIs that distinguish various error response bodies.
Trait Implementations§
Source§impl<E> Debug for Error<E>where
ResponseValue<E>: ErrorFormat,
impl<E> Debug for Error<E>where
ResponseValue<E>: ErrorFormat,
Source§impl<E> Display for Error<E>where
ResponseValue<E>: ErrorFormat,
impl<E> Display for Error<E>where
ResponseValue<E>: ErrorFormat,
Source§impl<E> Error for Error<E>where
ResponseValue<E>: ErrorFormat,
impl<E> Error for Error<E>where
ResponseValue<E>: ErrorFormat,
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
Source§impl<E> From<Infallible> for Error<E>
impl<E> From<Infallible> for Error<E>
Source§fn from(x: Infallible) -> Error<E>
fn from(x: Infallible) -> Error<E>
Source§impl<E> From<InvalidHeaderValue> for Error<E>
impl<E> From<InvalidHeaderValue> for Error<E>
Source§fn from(e: InvalidHeaderValue) -> Error<E>
fn from(e: InvalidHeaderValue) -> Error<E>
Auto Trait Implementations§
impl<E = ()> !Freeze for Error<E>
impl<E = ()> !RefUnwindSafe for Error<E>
impl<E> Send for Error<E>where
E: Send,
impl<E> Sync for Error<E>where
E: Sync,
impl<E> Unpin for Error<E>where
E: Unpin,
impl<E = ()> !UnwindSafe for Error<E>
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
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.