Error

Enum Error 

Source
pub enum Error {
Show 18 variants Api { message: String, error_type: String, code: Option<String>, }, ServerError { message: String, request_id: Option<String>, retry_suggested: bool, user_message: String, }, BadGateway { retry_after: Option<u64>, status_code: u16, }, ServiceUnavailable { retry_after: Option<u64>, retry_message: String, }, GatewayTimeout { retry_after: Option<u64>, }, RateLimited { retry_after: Option<u64>, retry_message: String, limit_type: Option<String>, }, AuthenticationFailed { message: String, suggestion: String, }, AuthorizationFailed { message: String, suggestion: String, }, ClientError { message: String, status_code: u16, field: Option<String>, suggestion: Option<String>, }, ContainerExpired { message: String, auto_handled: bool, }, Http(Error), HttpStatus(StatusCode), Json(Error), Stream(String), InvalidApiKey, ApiKeyNotFound, ContextRecovery(String), MaxRetriesExceeded { attempts: u32, },
}
Expand description

Error type for the crate

Variants§

§

Api

API error

Fields

§message: String

Error message

§error_type: String

Error type

§code: Option<String>

Error code

§

ServerError

Server error (500 Internal Server Error)

Fields

§message: String

Error message

§request_id: Option<String>

Request ID for debugging

§retry_suggested: bool

Whether retry is suggested

§user_message: String

User-friendly message

§

BadGateway

Bad Gateway error (502)

Fields

§retry_after: Option<u64>

When to retry (seconds from now)

§status_code: u16

Original status code

§

ServiceUnavailable

Service Unavailable error (503)

Fields

§retry_after: Option<u64>

When to retry (seconds from now)

§retry_message: String

Formatted retry message

§

GatewayTimeout

Gateway Timeout error (504)

Fields

§retry_after: Option<u64>

When to retry (seconds from now)

§

RateLimited

Rate limiting error (429)

Fields

§retry_after: Option<u64>

When the rate limit resets

§retry_message: String

Formatted retry message

§limit_type: Option<String>

Rate limit type (requests, tokens, etc.)

§

AuthenticationFailed

Authentication error (401)

Fields

§message: String

Error message

§suggestion: String

Suggested action for user

§

AuthorizationFailed

Authorization error (403)

Fields

§message: String

Error message

§suggestion: String

Suggested action for user

§

ClientError

Client error (400, 422)

Fields

§message: String

Error message

§status_code: u16

HTTP status code

§field: Option<String>

Field that caused the error (if available)

§suggestion: Option<String>

Suggested fix

§

ContainerExpired

Container expired error (special case of API error)

Fields

§message: String

Error message

§auto_handled: bool

Whether this error was automatically handled

§

Http(Error)

HTTP error

§

HttpStatus(StatusCode)

HTTP status error (fallback for unhandled status codes)

§

Json(Error)

JSON error

§

Stream(String)

Stream error

§

InvalidApiKey

Invalid API key

§

ApiKeyNotFound

API key not found in environment

§

ContextRecovery(String)

Context recovery error

§

MaxRetriesExceeded

Maximum retry attempts exceeded

Fields

§attempts: u32

Implementations§

Source§

impl Error

Source

pub fn is_container_expired(&self) -> bool

Returns true if this error indicates a container has expired

Source

pub fn is_recoverable(&self) -> bool

Returns true if this error can be automatically recovered from

Source

pub fn is_transient(&self) -> bool

Returns true if this is a transient error that should be retried

Source

pub fn retry_after(&self) -> Option<u64>

Returns the suggested retry delay in seconds

Source

pub fn user_message(&self) -> String

Returns a user-friendly error message

Source

pub fn container_expired(message: impl Into<String>, auto_handled: bool) -> Self

Creates a container expired error

Source

pub fn server_error( message: impl Into<String>, request_id: Option<String>, retry_suggested: bool, ) -> Self

Creates a server error with retry suggestion

Source

pub fn bad_gateway(retry_after: Option<u64>) -> Self

Creates a bad gateway error

Source

pub fn service_unavailable(retry_after: Option<u64>) -> Self

Creates a service unavailable error

Source

pub fn gateway_timeout(retry_after: Option<u64>) -> Self

Creates a gateway timeout error

Source

pub fn rate_limited( retry_after: Option<u64>, limit_type: Option<String>, ) -> Self

Creates a rate limited error

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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 Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

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> 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
Source§

impl<T> ErasedDestructor for T
where T: 'static,