Skip to main content

bothan_bybit/api/
error.rs

1//! Error types for Bybit API client operations.
2//!
3//! This module provides custom error types used throughout the Bybit API integration,
4//! particularly for handling WebSocket messages and price validation errors.
5
6/// Errors related to Bybit API client operations.
7#[derive(Debug, thiserror::Error)]
8pub enum Error {
9    /// Failed to parse a message from the WebSocket.
10    #[error("failed to parse message")]
11    ParseError(#[from] serde_json::Error),
12
13    /// Received an unsupported message type from the WebSocket.
14    #[error("unsupported message")]
15    UnsupportedWebsocketMessageType,
16}
17
18/// Errors that can occur while listening for Bybit WebSocket events.
19///
20/// These errors can occur during subscription to asset updates or when processing
21/// incoming messages from the Bybit WebSocket stream.
22#[derive(Debug, thiserror::Error)]
23pub enum ListeningError {
24    /// An error occurred while processing a WebSocket message.
25    #[error(transparent)]
26    Error(#[from] Error),
27
28    /// An invalid price was encountered while parsing a message.
29    #[error(transparent)]
30    InvalidPrice(#[from] rust_decimal::Error),
31}