pub enum Error {
#[non_exhaustive] Api {
status: u16,
name: String,
message: String,
retry_after: Option<Duration>,
},
Signature(String),
Config(String),
Json(Error),
}Expand description
Everything a call or a signature check can fail with.
Variants§
#[non_exhaustive]Api
The API answered with an error, or could not be reached.
status is the HTTP status, or 0 when Ha Tang was not reached (network error, timeout).
name is the API’s error code (validation_error, not_found, rate_limit_exceeded…).
retry_after is the API’s retry-after header (sent with 429 rate_limit_exceeded).
Match it with Error::Api { status, name, .. }: more fields may come.
Fields
This variant is marked as non-exhaustive
Signature(String)
A webhook delivery or IPN call whose signature (or timestamp) does not match.
Config(String)
The client could not be set up (no API key, an invalid base URL…).
Json(Error)
A request body could not be encoded, or a response did not have the expected shape.
Implementations§
Source§impl Error
impl Error
Sourcepub fn status(&self) -> Option<u16>
pub fn status(&self) -> Option<u16>
The HTTP status of an API error (0 when Ha Tang was not reached); None for other errors.
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
The API’s error code (validation_error, not_found…); None for other errors.
Sourcepub fn retryable(&self) -> bool
pub fn retryable(&self) -> bool
True when the same call (with the same idempotency key) can succeed later: Ha Tang was
unreachable, a rate limit (429 rate_limit_exceeded), a request still running with the same
idempotency key (409 concurrent_idempotent_requests), or a server error. Wait
Error::retry_after when it is set, otherwise back off.
The daily email quota is not retryable this way: see Error::is_quota_exceeded.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
How long the API asked to wait before retrying (its retry-after header), if it said.
Sourcepub fn is_quota_exceeded(&self) -> bool
pub fn is_quota_exceeded(&self) -> bool
True when the business reached its daily email quota (429 daily_quota_exceeded):
sends work again after midnight UTC, or once the quota is raised.
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()