#[non_exhaustive]pub enum KrakenError {
Show 18 variants
ConnectionFailed {
url: String,
reason: String,
},
ConnectionTimeout {
url: String,
timeout: Duration,
},
WebSocket(String),
InvalidJson {
message: String,
raw: Option<String>,
},
ChecksumMismatch {
symbol: String,
expected: u32,
computed: u32,
},
UnexpectedMessage(String),
SubscriptionRejected {
channel: String,
reason: String,
},
SymbolNotFound {
symbol: String,
},
SubscriptionTimeout {
timeout: Duration,
},
AuthenticationFailed {
reason: String,
},
TokenExpired,
RateLimited {
retry_after: Duration,
},
CloudflareLimit,
ApiError {
code: Option<KrakenErrorCode>,
message: String,
raw: String,
recovery: RecoveryStrategy,
},
ChannelClosed,
ShuttingDown,
InvalidState {
expected: String,
actual: String,
},
Configuration(String),
}Expand description
Main error type for Havklo SDK operations
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ConnectionFailed
Failed to establish WebSocket connection
ConnectionTimeout
Connection attempt timed out
WebSocket(String)
WebSocket protocol error
InvalidJson
Failed to parse JSON message
ChecksumMismatch
Orderbook checksum mismatch
UnexpectedMessage(String)
Unexpected message format
SubscriptionRejected
Subscription was rejected by server
SymbolNotFound
Symbol not found or not supported
SubscriptionTimeout
Subscription request timed out
AuthenticationFailed
Authentication failed
TokenExpired
Token has expired
RateLimited
Rate limited by server
CloudflareLimit
Cloudflare connection limit exceeded
ApiError
Parsed Kraken API error with structured recovery
Fields
code: Option<KrakenErrorCode>The parsed error code (if recognized)
recovery: RecoveryStrategyRecovery strategy for this error
ChannelClosed
Internal channel was closed unexpectedly
ShuttingDown
SDK is shutting down
InvalidState
Invalid state transition
Configuration(String)
Configuration error
Implementations§
Source§impl KrakenError
impl KrakenError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if this error is potentially recoverable via retry
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
Returns suggested retry delay, if applicable
Sourcepub fn requires_reconnect(&self) -> bool
pub fn requires_reconnect(&self) -> bool
Returns true if this error requires reconnection
Sourcepub fn requires_reauth(&self) -> bool
pub fn requires_reauth(&self) -> bool
Returns true if this error requires re-authentication
Sourcepub fn is_rate_limit(&self) -> bool
pub fn is_rate_limit(&self) -> bool
Returns true if this is a rate limit error
Sourcepub fn recovery_strategy(&self) -> RecoveryStrategy
pub fn recovery_strategy(&self) -> RecoveryStrategy
Get the recovery strategy for this error
Sourcepub fn checksum_mismatch(
symbol: impl Into<String>,
expected: u32,
computed: u32,
) -> Self
pub fn checksum_mismatch( symbol: impl Into<String>, expected: u32, computed: u32, ) -> Self
Create a checksum mismatch error
Sourcepub fn subscription_rejected(
channel: impl Into<String>,
reason: impl Into<String>,
) -> Self
pub fn subscription_rejected( channel: impl Into<String>, reason: impl Into<String>, ) -> Self
Create a subscription rejected error
Sourcepub fn from_api_error(error: impl AsRef<str>) -> Self
pub fn from_api_error(error: impl AsRef<str>) -> Self
Create an API error from a Kraken error string
This parses the error string and determines the appropriate recovery strategy.
Sourcepub fn from_api_errors(errors: &[String]) -> Self
pub fn from_api_errors(errors: &[String]) -> Self
Create an API error from multiple Kraken error strings
Returns the first error if multiple are present (Kraken returns arrays).
Sourcepub fn error_code(&self) -> Option<KrakenErrorCode>
pub fn error_code(&self) -> Option<KrakenErrorCode>
Get the error code if this is an API error
Trait Implementations§
Source§impl Clone for KrakenError
impl Clone for KrakenError
Source§impl Debug for KrakenError
impl Debug for KrakenError
Source§impl Display for KrakenError
impl Display for KrakenError
Source§impl Error for KrakenError
impl Error for KrakenError
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
use the Display impl or to_string()