#[non_exhaustive]pub enum ZBError {
ExplicitError(String),
ApiError {
status: u16,
message: String,
},
JsonError(Error),
IntParseError(ParseIntError),
RequestError(Error),
IOError(Error),
}Expand description
Every error the SDK returns.
#[non_exhaustive]: a variant added later is not a breaking change, so a
match on it needs a _ arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ExplicitError(String)
An error the SDK raised itself: an invalid argument or URL caught before a request, or a local failure such as a file that cannot be written.
ApiError
The API answered and the answer is a failure: a non-2xx status, an HTML
error page, an error body on an HTTP 200, a bulk getfile error, or a
batch_validate account-level error. status is the HTTP status of that
response, so callers can tell a 403 from Cloudflare apart from a 400/404
from the API and a 429 from the Warmup rate limit. A 2xx body that is
not strict JSON, or is JSON of the wrong shape for the call (0,
"x", null, a list where an object is expected, a field of the wrong
type), is an ApiError with status 200. Both the validation client and
the Warmup client return it.
JsonError(Error)
A serde_json::Error converted with From (?). The SDK’s own calls
no longer return it: a 2xx body of the wrong shape is an
ZBError::ApiError with status 200. Kept for code that converts its
own serde errors. The inner error names only the kind of error and its
line and column, never the input (serde’s own message quotes the value
it rejected).
IntParseError(ParseIntError)
The SDK’s own calls no longer return it: an unreadable Credits value
is an ZBError::ApiError with status 200. Kept for compatibility.
RequestError(Error)
IOError(Error)
Implementations§
Source§impl ZBError
impl ZBError
pub fn explicit(string: &str) -> ZBError
pub fn api(status: u16, message: impl Into<String>) -> ZBError
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
The HTTP status of a failed API response: Some for every
ZBError::ApiError, including a failure the API reports with an HTTP
200 and a 2xx body that is not JSON or not the call’s shape (Some(200)).
None when no response is involved: an argument or URL rejected before
a request, or a transport error.
Trait Implementations§
Source§impl Error for ZBError
impl Error for ZBError
1.30.0 · 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()