#[non_exhaustive]pub enum Error {
Http(CanopyHttpError),
Decode {
path: String,
source: Error,
},
Encode {
path: String,
source: Error,
},
Request {
path: String,
source: Error,
},
Compress {
path: String,
source: Error,
},
Transport(Box<dyn Error + Send + Sync>),
}Expand description
Anything that can go wrong calling canopy.
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.
Http(CanopyHttpError)
Canopy answered with a status outside the success range.
Decode
The response body was not the JSON the endpoint declares.
Encode
The request body could not be serialised.
Request
Building the HTTP request failed.
Compress
Compressing the request body failed.
Transport(Box<dyn Error + Send + Sync>)
The transport could not obtain any response.
Distinct from Error::Http, which is a response that reports failure.
Implementations§
Source§impl Error
impl Error
Sourcepub fn transport<E: Error + Send + Sync + 'static>(err: E) -> Self
pub fn transport<E: Error + Send + Sync + 'static>(err: E) -> Self
Wrap a transport-side failure to obtain a response.
Sourcepub fn http(&self) -> Option<&CanopyHttpError>
pub fn http(&self) -> Option<&CanopyHttpError>
The CanopyHttpError this error carries, if it is one.
Endpoints give particular statuses meaning, so a caller branching on a documented status reads it through here.
Sourcepub fn status(&self) -> Option<StatusCode>
pub fn status(&self) -> Option<StatusCode>
The status canopy answered with, if this is an unsuccessful response.
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()
Source§impl From<CanopyHttpError> for Error
impl From<CanopyHttpError> for Error
Source§fn from(source: CanopyHttpError) -> Self
fn from(source: CanopyHttpError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !Freeze for Error
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
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