Skip to main content

HlError

Enum HlError 

Source
#[non_exhaustive]
pub enum HlError {
Show 14 variants Signing { message: String, source: Option<Box<dyn Error + Send + Sync>>, }, Serialization { message: String, source: Option<Box<dyn Error + Send + Sync>>, }, Http { message: String, source: Option<Box<dyn Error + Send + Sync>>, }, Timeout { message: String, source: Option<Box<dyn Error + Send + Sync>>, }, WebSocket { message: String, source: Option<Box<dyn Error + Send + Sync>>, }, Api { status: u16, body: String, }, Rejected { reason: String, }, InvalidAddress(String), RateLimited { retry_after_ms: u64, message: String, }, Parse(String), Validation(String), Config(String), WsCancelled, WsReconnectExhausted { attempts: u32, },
}
Expand description

Errors that can occur in Hyperliquid 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.
§

Signing

An error occurred during EIP-712 signing.

Fields

§message: String

Human-readable description of the signing failure.

§source: Option<Box<dyn Error + Send + Sync>>

Optional underlying error that caused this failure.

§

Serialization

An error occurred during serialization or deserialization.

Fields

§message: String

Human-readable description of the serialization failure.

§source: Option<Box<dyn Error + Send + Sync>>

Optional underlying error that caused this failure.

§

Http

An HTTP transport error (connection refused, DNS failure, etc.).

Fields

§message: String

Human-readable description of the HTTP failure.

§source: Option<Box<dyn Error + Send + Sync>>

Optional underlying error that caused this failure.

§

Timeout

The request timed out before receiving a response.

Fields

§message: String

Human-readable description of the timeout.

§source: Option<Box<dyn Error + Send + Sync>>

Optional underlying error that caused this failure.

§

WebSocket

A WebSocket transport error (connection lost, frame error, etc.).

Fields

§message: String

Human-readable description of the WebSocket failure.

§source: Option<Box<dyn Error + Send + Sync>>

Optional underlying error that caused this failure.

§

Api

The API returned a non-2xx HTTP status code.

Fields

§status: u16

HTTP status code returned by the API.

§body: String

Response body text.

§

Rejected

The exchange rejected the order.

Fields

§reason: String

Rejection reason provided by the exchange.

§

InvalidAddress(String)

The provided Ethereum address is invalid.

§

RateLimited

The API returned HTTP 429 (rate limited).

Fields

§retry_after_ms: u64

Suggested wait time in milliseconds before retrying.

§message: String

Human-readable rate-limit message.

§

Parse(String)

A JSON or data parsing error.

§

Validation(String)

An input validation error (bad parameters, invalid amounts, unknown assets).

§

Config(String)

A configuration error (invalid settings, missing keys, etc.).

§

WsCancelled

The WebSocket reconnect loop was cancelled.

§

WsReconnectExhausted

The WebSocket reconnect loop exhausted all retry attempts.

Fields

§attempts: u32

Number of reconnect attempts made before giving up.

Implementations§

Source§

impl HlError

Source

pub fn http(message: impl Into<String>) -> Self

Create an Http error without an underlying source.

Source

pub fn timeout(message: impl Into<String>) -> Self

Create a Timeout error without an underlying source.

Source

pub fn signing(message: impl Into<String>) -> Self

Create a Signing error without an underlying source.

Source

pub fn serialization(message: impl Into<String>) -> Self

Create a Serialization error without an underlying source.

Source

pub fn websocket(message: impl Into<String>) -> Self

Create a WebSocket error without an underlying source.

Source

pub fn is_retryable(&self) -> bool

Returns true if the error is retryable (network timeout, 5xx, or 429).

Source

pub fn retry_after_ms(&self) -> Option<u64>

If this is a RateLimited error, returns the suggested wait time in milliseconds.

Trait Implementations§

Source§

impl Debug for HlError

Source§

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

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

impl Display for HlError

Source§

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

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

impl Error for HlError

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> 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.