#[non_exhaustive]pub enum Error {
Api(Box<ApiError>),
Transport(TransportError),
Read(Error),
ResponseTooLarge {
limit: u64,
},
Decode {
source: Error,
body: String,
},
InvalidBaseUrl(String),
Redirect {
status: u16,
location: Option<String>,
},
InvalidToken,
InvalidPath(String),
}Expand description
Everything that can go wrong with a request.
New variants may be added in minor versions, so a match needs a _ arm.
For the common checks there are helpers like Error::is_not_found.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Api(Box<ApiError>)
The server answered with a non-2xx status.
Transport(TransportError)
The request did not reach the server or the response could not be read.
Read(Error)
The response body could not be read completely.
ResponseTooLarge
The response body is larger than ClientBuilder::max_response_size.
Decode
The response body did not match the expected shape.
InvalidBaseUrl(String)
Redirect
The server answered with a redirect that is not followed (301, 302, 303: it would repeat the request as GET without its body).
InvalidToken
The token contains characters not allowed in an HTTP header.
InvalidPath(String)
A path parameter was empty, . or ..; the request was not sent.
Implementations§
Source§impl Error
impl Error
Sourcepub fn api(&self) -> Option<&ApiError>
pub fn api(&self) -> Option<&ApiError>
The error response of the server, if it answered with a non-2xx status.
Sourcepub fn status(&self) -> Option<u16>
pub fn status(&self) -> Option<u16>
HTTP status of an error response or an unfollowed redirect.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
404 Not Found: the object does not exist or the person may not see it.
401 Unauthorized: no token, or an expired one.
Sourcepub fn is_forbidden(&self) -> bool
pub fn is_forbidden(&self) -> bool
403 Forbidden: logged in, but without permission.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
The request took longer than the timeout.
Sourcepub fn is_connect(&self) -> bool
pub fn is_connect(&self) -> bool
No connection to the server (wrong address, network down, connect timeout).
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()