pub enum OdosError {
Show 14 variants
Http(Error),
Api {
status: StatusCode,
message: String,
},
Json(Error),
Hex(FromHexError),
InvalidInput(String),
MissingData(String),
UnsupportedChain {
chain_id: u64,
},
Contract(String),
TransactionAssembly(String),
QuoteRequest(String),
Configuration(String),
Timeout(String),
RateLimit(String),
Internal(String),
}Expand description
Comprehensive error types for the Odos SDK
This enum provides detailed error types for different failure scenarios, allowing users to handle specific error conditions appropriately.
§Error Categories
- Network Errors: HTTP, timeout, and connectivity issues
- API Errors: Responses from the Odos service indicating various failures
- Input Errors: Invalid parameters or missing required data
- System Errors: Rate limiting and internal failures
§Retryable Errors
Some error types are marked as retryable (see OdosError::is_retryable):
- Timeout errors
- Certain HTTP errors (5xx status codes, connection issues)
- Rate limiting errors
- Some API errors (server errors, rate limits)
§Examples
use odos_sdk::{OdosError, Result};
use reqwest::StatusCode;
// Create different error types
let api_error = OdosError::api_error(StatusCode::BAD_REQUEST, "Invalid input".to_string());
let timeout_error = OdosError::timeout_error("Request timed out");
let rate_limit_error = OdosError::rate_limit_error("Too many requests");
// Check if errors are retryable
assert!(!api_error.is_retryable()); // 4xx errors are not retryable
assert!(timeout_error.is_retryable()); // Timeouts are retryable
assert!(rate_limit_error.is_retryable()); // Rate limits are retryable
// Get error categories for metrics
assert_eq!(api_error.category(), "api");
assert_eq!(timeout_error.category(), "timeout");
assert_eq!(rate_limit_error.category(), "rate_limit");Variants§
Http(Error)
HTTP request errors
Api
API errors returned by the Odos service
Json(Error)
JSON serialization/deserialization errors
Hex(FromHexError)
Hex decoding errors
InvalidInput(String)
Invalid input parameters
MissingData(String)
Missing required data
UnsupportedChain
Chain not supported
Contract(String)
Contract interaction errors
TransactionAssembly(String)
Transaction assembly errors
QuoteRequest(String)
Quote request errors
Configuration(String)
Configuration errors
Timeout(String)
Timeout errors
RateLimit(String)
Rate limit exceeded
Internal(String)
Generic internal error
Implementations§
Source§impl OdosError
impl OdosError
Sourcepub fn api_error(status: StatusCode, message: String) -> Self
pub fn api_error(status: StatusCode, message: String) -> Self
Create an API error from response
Sourcepub fn invalid_input(message: impl Into<String>) -> Self
pub fn invalid_input(message: impl Into<String>) -> Self
Create an invalid input error
Sourcepub fn missing_data(message: impl Into<String>) -> Self
pub fn missing_data(message: impl Into<String>) -> Self
Create a missing data error
Sourcepub fn unsupported_chain(chain_id: u64) -> Self
pub fn unsupported_chain(chain_id: u64) -> Self
Create an unsupported chain error
Sourcepub fn contract_error(message: impl Into<String>) -> Self
pub fn contract_error(message: impl Into<String>) -> Self
Create a contract error
Sourcepub fn transaction_assembly_error(message: impl Into<String>) -> Self
pub fn transaction_assembly_error(message: impl Into<String>) -> Self
Create a transaction assembly error
Sourcepub fn quote_request_error(message: impl Into<String>) -> Self
pub fn quote_request_error(message: impl Into<String>) -> Self
Create a quote request error
Sourcepub fn configuration_error(message: impl Into<String>) -> Self
pub fn configuration_error(message: impl Into<String>) -> Self
Create a configuration error
Sourcepub fn timeout_error(message: impl Into<String>) -> Self
pub fn timeout_error(message: impl Into<String>) -> Self
Create a timeout error
Sourcepub fn rate_limit_error(message: impl Into<String>) -> Self
pub fn rate_limit_error(message: impl Into<String>) -> Self
Create a rate limit error
Sourcepub fn internal_error(message: impl Into<String>) -> Self
pub fn internal_error(message: impl Into<String>) -> Self
Create an internal error
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if the error is retryable
Trait Implementations§
Source§impl Error for OdosError
impl Error for OdosError
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<FromHexError> for OdosError
impl From<FromHexError> for OdosError
Source§fn from(source: FromHexError) -> Self
fn from(source: FromHexError) -> Self
Source§impl From<OdosChainError> for OdosError
impl From<OdosChainError> for OdosError
Source§fn from(err: OdosChainError) -> Self
fn from(err: OdosChainError) -> Self
Auto Trait Implementations§
impl Freeze for OdosError
impl !RefUnwindSafe for OdosError
impl Send for OdosError
impl Sync for OdosError
impl Unpin for OdosError
impl !UnwindSafe for OdosError
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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.