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§
Sourcefn error_code(&self) -> Option<&str>
fn error_code(&self) -> Option<&str>
Get the provider-specific error code if available.
Sourcefn is_retryable(&self) -> bool
fn is_retryable(&self) -> bool
Check if this error is retryable.
Returns true if the operation that caused this error can be safely retried.
Sourcefn is_rate_limited(&self) -> bool
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.
Sourcefn is_auth_error(&self) -> bool
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.
Sourcefn retry_after(&self) -> Option<Duration>
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§
Sourcefn is_invalid_input(&self) -> bool
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.
Check if this error is due to service unavailability.
Returns true if the error was caused by the service being temporarily unavailable.
Sourcefn is_content_filtered(&self) -> bool
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.