#[non_exhaustive]pub enum HonchoError {
Show 18 variants
BadRequest {
message: String,
body: Option<Value>,
},
Authentication {
message: String,
},
PermissionDenied {
message: String,
},
NotFound {
message: String,
},
Conflict {
message: String,
body: Option<Value>,
},
UnprocessableEntity {
message: String,
body: Option<Value>,
},
RateLimit {
message: String,
retry_after: Option<Duration>,
},
Client {
status: u16,
message: String,
},
Server {
status: u16,
message: String,
},
Timeout {
message: String,
},
Connection {
message: String,
},
Transport(Error),
Decode {
path: String,
source: Error,
},
Serialization {
path: String,
source: Error,
},
Io(Error),
Configuration(String),
Validation(String),
PartialFailure {
messages: Vec<Message>,
sent: usize,
error: Box<HonchoError>,
},
}Expand description
Error type for all Honcho SDK operations.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BadRequest
400 Bad Request
Fields
Authentication
401 Authentication Error
PermissionDenied
403 Permission Denied
NotFound
404 Not Found
Conflict
409 Conflict
UnprocessableEntity
422 Unprocessable Entity
RateLimit
429 Rate Limit Exceeded
Fields
Client
Unmapped or unexpected HTTP status not covered by a dedicated variant.
from_response routes every 4xx status without a dedicated variant here
(e.g. 405, 408, 413), as well as unexpected 3xx redirects and any other
status that does not match a known category (e.g. 600+ from a
misbehaving proxy). The status field preserves the original code.
Server
5xx Server Error
Timeout
Request timed out.
Connection
Connection error.
Transport(Error)
HTTP transport error from reqwest.
Decode
Failed to decode response body.
Serialization
Failed to serialize a value before sending it to the API.
Fields
Io(Error)
IO error.
Configuration(String)
Configuration error.
Validation(String)
Validation error (e.g. duplicate inputs, invalid arguments).
PartialFailure
Partial failure in a chunked batch operation.
Some chunks succeeded before an error occurred. The messages field
contains the successfully created messages from earlier chunks, and
error holds the underlying error that caused the failure.
Implementations§
Source§impl HonchoError
impl HonchoError
Sourcepub fn code(&self) -> &'static str
pub fn code(&self) -> &'static str
Returns a stable error code string for pattern matching.
Parity with Python SDK’s error.code field.
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
Returns the HTTP status code if this error originated from an HTTP response.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns whether the error matches the SDK retry policy.
PartialFailure is never retryable: the chunked batch already sent
earlier messages, so auto-retrying the whole request would duplicate
them. This is intentionally decoupled from
retry_after, which still surfaces any
Retry-After hint from the underlying error so callers can decide how
long to wait before a manual retry.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
Returns the suggested wait time for rate-limited requests.
For PartialFailure, delegates to the underlying
error so callers still learn how long to wait even though the batch is
not auto-retried (see is_retryable).
Sourcepub fn is_partial_failure(&self) -> bool
pub fn is_partial_failure(&self) -> bool
Returns true if this is a partial failure with some successful messages.
Sourcepub fn into_partial_failure(self) -> Option<(Vec<Message>, Box<HonchoError>)>
pub fn into_partial_failure(self) -> Option<(Vec<Message>, Box<HonchoError>)>
Extract the partial failure data, consuming the error.
Returns Some((messages, error)) if this is a PartialFailure,
None otherwise.
Sourcepub fn message(&self) -> &str
pub fn message(&self) -> &str
Returns the human-readable error message.
Limitation (planned for a future breaking change): for Transport,
Io, Decode, and Serialization the returned string is a fixed
placeholder rather than the underlying source error’s detail. Inspect
the source via Error::source for the full
description.
Trait Implementations§
Source§impl Debug for HonchoError
impl Debug for HonchoError
Source§impl Display for HonchoError
impl Display for HonchoError
Source§impl Error for HonchoError
impl Error for HonchoError
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()