Skip to main content

KrakenError

Enum KrakenError 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

ConnectionFailed

Failed to establish WebSocket connection

Fields

§reason: String

Error message (converted from io::Error for Clone support)

§

ConnectionTimeout

Connection attempt timed out

Fields

§timeout: Duration
§

WebSocket(String)

WebSocket protocol error

§

InvalidJson

Failed to parse JSON message

Fields

§message: String
§

ChecksumMismatch

Orderbook checksum mismatch

Fields

§symbol: String
§expected: u32
§computed: u32
§

UnexpectedMessage(String)

Unexpected message format

§

SubscriptionRejected

Subscription was rejected by server

Fields

§channel: String
§reason: String
§

SymbolNotFound

Symbol not found or not supported

Fields

§symbol: String
§

SubscriptionTimeout

Subscription request timed out

Fields

§timeout: Duration
§

AuthenticationFailed

Authentication failed

Fields

§reason: String
§

TokenExpired

Token has expired

§

RateLimited

Rate limited by server

Fields

§retry_after: Duration
§

CloudflareLimit

Cloudflare connection limit exceeded

§

ApiError

Parsed Kraken API error with structured recovery

Fields

§code: Option<KrakenErrorCode>

The parsed error code (if recognized)

§message: String

Human-readable message

§raw: String

Raw error string from Kraken

§recovery: RecoveryStrategy

Recovery strategy for this error

§

ChannelClosed

Internal channel was closed unexpectedly

§

ShuttingDown

SDK is shutting down

§

InvalidState

Invalid state transition

Fields

§expected: String
§actual: String
§

Configuration(String)

Configuration error

Implementations§

Source§

impl KrakenError

Source

pub fn is_retryable(&self) -> bool

Returns true if this error is potentially recoverable via retry

Source

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

Returns suggested retry delay, if applicable

Source

pub fn requires_reconnect(&self) -> bool

Returns true if this error requires reconnection

Source

pub fn requires_reauth(&self) -> bool

Returns true if this error requires re-authentication

Source

pub fn is_rate_limit(&self) -> bool

Returns true if this is a rate limit error

Source

pub fn recovery_strategy(&self) -> RecoveryStrategy

Get the recovery strategy for this error

Source

pub fn checksum_mismatch( symbol: impl Into<String>, expected: u32, computed: u32, ) -> Self

Create a checksum mismatch error

Source

pub fn subscription_rejected( channel: impl Into<String>, reason: impl Into<String>, ) -> Self

Create a subscription rejected error

Source

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.

Source

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).

Source

pub fn error_code(&self) -> Option<KrakenErrorCode>

Get the error code if this is an API error

Trait Implementations§

Source§

impl Clone for KrakenError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KrakenError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for KrakenError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for KrakenError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.