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