pub enum RainyError {
Authentication {
code: String,
message: String,
retryable: bool,
},
InvalidRequest {
code: String,
message: String,
details: Option<Value>,
},
Provider {
code: String,
message: String,
provider: String,
retryable: bool,
},
RateLimit {
code: String,
message: String,
retry_after: Option<u64>,
current_usage: Option<String>,
},
InsufficientCredits {
code: String,
message: String,
current_credits: f64,
estimated_cost: f64,
reset_date: Option<String>,
},
Network {
message: String,
retryable: bool,
source_error: Option<String>,
},
Api {
code: String,
message: String,
status_code: u16,
retryable: bool,
request_id: Option<String>,
},
Timeout {
message: String,
duration_ms: u64,
},
Serialization {
message: String,
source_error: Option<String>,
},
}Expand description
The comprehensive error type for all operations within the Rainy SDK.
RainyError is an enumeration of all possible errors that can occur,
providing detailed context for each error variant.
Variants§
Authentication
An error related to authentication, such as an invalid or expired API key.
Fields
InvalidRequest
An error due to an invalid request, such as a missing required field.
Fields
Provider
An error that originates from an underlying AI provider (e.g., OpenAI, Anthropic).
Fields
RateLimit
An error indicating that the rate limit for the API has been exceeded.
Fields
InsufficientCredits
An error indicating that the account has insufficient credits to perform the request.
Fields
Network
An error related to network connectivity or HTTP-level issues.
Fields
Api
A generic API error that doesn’t fit into the other categories.
Fields
Timeout
An error indicating that the request timed out.
Fields
Serialization
An error that occurs during serialization or deserialization of data.
Implementations§
Source§impl RainyError
impl RainyError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Checks if the error is considered retryable.
Some errors, like network issues or rate limiting, are transient and can be resolved by retrying the request.
§Returns
true if the error is retryable, false otherwise.
Sourcepub fn retry_after(&self) -> Option<u64>
pub fn retry_after(&self) -> Option<u64>
Returns the recommended delay in seconds before a retry, if applicable.
This is typically used with RateLimit errors.
§Returns
An Option<u64> containing the retry delay in seconds, or None if not applicable.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
Returns the unique request ID associated with the error, if available.
This is useful for debugging and support requests.
Trait Implementations§
Source§impl Clone for RainyError
impl Clone for RainyError
Source§fn clone(&self) -> RainyError
fn clone(&self) -> RainyError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RainyError
impl Debug for RainyError
Source§impl Display for RainyError
impl Display for RainyError
Source§impl Error for RainyError
impl Error for RainyError
1.30.0 · 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
Source§impl From<Error> for RainyError
Converts a reqwest::Error into a RainyError.
impl From<Error> for RainyError
Converts a reqwest::Error into a RainyError.
This implementation categorizes reqwest errors into Timeout, Network,
or other appropriate RainyError variants.
Source§impl From<Error> for RainyError
Converts a serde_json::Error into a RainyError.
impl From<Error> for RainyError
Converts a serde_json::Error into a RainyError.
This is used for errors that occur during the serialization or deserialization of JSON data.
Source§impl From<InvalidHeaderValue> for RainyError
Converts a reqwest::header::InvalidHeaderValue into a RainyError.
impl From<InvalidHeaderValue> for RainyError
Converts a reqwest::header::InvalidHeaderValue into a RainyError.
This is used when an invalid value is provided for an HTTP header.
Source§fn from(err: InvalidHeaderValue) -> Self
fn from(err: InvalidHeaderValue) -> Self
Auto Trait Implementations§
impl Freeze for RainyError
impl RefUnwindSafe for RainyError
impl Send for RainyError
impl Sync for RainyError
impl Unpin for RainyError
impl UnwindSafe for RainyError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.