Trait ProviderError

Source
pub trait ProviderError:
    Error
    + Send
    + Sync
    + 'static {
    // Required methods
    fn error_code(&self) -> Option<&str>;
    fn is_retryable(&self) -> bool;
    fn is_rate_limited(&self) -> bool;
    fn is_auth_error(&self) -> bool;
    fn retry_after(&self) -> Option<Duration>;

    // Provided methods
    fn is_invalid_input(&self) -> bool { ... }
    fn is_service_unavailable(&self) -> bool { ... }
    fn is_content_filtered(&self) -> bool { ... }
}
Expand description

Common trait for all provider errors.

This trait provides a consistent interface for error handling across different providers, allowing clients to handle errors generically while still preserving provider-specific error information.

Required Methods§

Source

fn error_code(&self) -> Option<&str>

Get the provider-specific error code if available.

Source

fn is_retryable(&self) -> bool

Check if this error is retryable.

Returns true if the operation that caused this error can be safely retried.

Source

fn is_rate_limited(&self) -> bool

Check if this error is due to rate limiting.

Returns true if the error was caused by hitting rate limits.

Source

fn is_auth_error(&self) -> bool

Check if this error is due to authentication issues.

Returns true if the error was caused by invalid or missing credentials.

Source

fn retry_after(&self) -> Option<Duration>

Get the suggested retry delay if this is a rate limit error.

Returns the duration to wait before retrying, if specified by the provider.

Provided Methods§

Source

fn is_invalid_input(&self) -> bool

Check if this error is due to invalid input.

Returns true if the error was caused by invalid request parameters.

Source

fn is_service_unavailable(&self) -> bool

Check if this error is due to service unavailability.

Returns true if the error was caused by the service being temporarily unavailable.

Source

fn is_content_filtered(&self) -> bool

Check if this error is due to content filtering.

Returns true if the error was caused by content being filtered or blocked.

Implementors§