Skip to main content

HonchoError

Enum HonchoError 

Source
#[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
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.
§

BadRequest

400 Bad Request

Fields

§message: String

Error message from the API.

§body: Option<Value>

Full response body if available.

§

Authentication

401 Authentication Error

Fields

§message: String

Error message.

§

PermissionDenied

403 Permission Denied

Fields

§message: String

Error message.

§

NotFound

404 Not Found

Fields

§message: String

Error message.

§

Conflict

409 Conflict

Fields

§message: String

Error message.

§body: Option<Value>

Full response body if available.

§

UnprocessableEntity

422 Unprocessable Entity

Fields

§message: String

Error message.

§body: Option<Value>

Full response body if available.

§

RateLimit

429 Rate Limit Exceeded

Fields

§message: String

Error message.

§retry_after: Option<Duration>

Suggested wait time from Retry-After header.

§

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.

Fields

§status: u16

HTTP status code.

§message: String

Error message.

§

Server

5xx Server Error

Fields

§status: u16

HTTP status code.

§message: String

Error message.

§

Timeout

Request timed out.

Fields

§message: String

Error message.

§

Connection

Connection error.

Fields

§message: String

Error message.

§

Transport(Error)

HTTP transport error from reqwest.

§

Decode

Failed to decode response body.

Fields

§path: String

JSON path where decoding failed.

§source: Error

The underlying serde error.

§

Serialization

Failed to serialize a value before sending it to the API.

Fields

§path: String

Logical name of the value being serialized (e.g. a request DTO name).

§source: Error

The underlying serde error.

§

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.

Fields

§messages: Vec<Message>

Messages that were successfully created before the failure.

§sent: usize

The number of messages successfully sent.

§error: Box<HonchoError>

The underlying error that caused the partial failure.

Implementations§

Source§

impl HonchoError

Source

pub fn code(&self) -> &'static str

Returns a stable error code string for pattern matching.

Parity with Python SDK’s error.code field.

Source

pub fn status_code(&self) -> Option<u16>

Returns the HTTP status code if this error originated from an HTTP response.

Source

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.

Source

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).

Source

pub fn is_partial_failure(&self) -> bool

Returns true if this is a partial failure with some successful messages.

Source

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.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for HonchoError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for HonchoError

Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for HonchoError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for HonchoError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more