#[non_exhaustive]pub enum Error {
Connection(ConnectionError),
Status(Box<Response>),
Decode(DecodeError),
Invalid(InvalidRequest),
}Expand description
Why an outgoing request failed.
? converts it into laravel::Error. A failure that reaches a handler
becomes a 500 response, and Laravel reports it with the URL but without the query string.
use laravel::http::client::{self, Error};
match client::get("https://example.com").ensure_successful().await {
Ok(response) => {
// Use the response here...
}
Err(Error::Connection(error)) if error.is_timeout() => {
// Try again later...
}
Err(Error::Status(response)) if response.status() == 404 => {
// Treat the record as deleted...
}
Err(error) => return Err(error.into()),
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Connection(ConnectionError)
No response arrived, because the host couldn’t be found or reached, TLS failed, the request timed out, or a fake failed the connection.
Status(Box<Response>)
The response’s status was outside 2xx, and the request called
ensure_successful or
retry, or the code called
Response::ensure_successful.
Decode(DecodeError)
The response’s body isn’t JSON of the expected type.
Invalid(InvalidRequest)
Implementations§
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)>
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()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Forget for Error
impl Freeze for Errorwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
&'static str: Freeze,
*const ArcInner<dyn Error + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Error + Sync + Send>>: Freeze,
*const Response is !null: Freeze,
PhantomData<Response>: Freeze,
NonZero<u16>: Freeze,
*const ArcInner<Error> is !null: Freeze,
PhantomData<ArcInner<Error>>: Freeze,
impl Move for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Errorwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<dyn Error + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Error + Sync + Send>>: UnsafeUnpin,
*const Response is !null: UnsafeUnpin,
PhantomData<Response>: UnsafeUnpin,
NonZeroU16Inner: UnsafeUnpin,
*const ArcInner<Error> is !null: UnsafeUnpin,
PhantomData<ArcInner<Error>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoMarkdown for Twhere
T: Display,
impl<T> IntoMarkdown for Twhere
T: Display,
Creates a shared type from an unshared type.