bothan_bitfinex/api/
error.rs

1//! Error types for Bitfinex API client operations.
2//!
3//! This module provides custom error types used throughout the Bitfinex API integration,
4//! particularly for handling REST API requests and price validation errors.
5
6use thiserror::Error;
7
8/// Errors related to Bitfinex API client configuration and building.
9///
10/// These errors can occur during the construction of the Bitfinex REST API client,
11/// such as invalid URLs or HTTP client creation failures.
12#[derive(Debug, Error)]
13pub enum BuildError {
14    /// Indicates that the provided URL is invalid and cannot be parsed.
15    #[error("invalid url")]
16    InvalidURL(#[from] url::ParseError),
17
18    /// Indicates a failure to build the HTTP client for the Bitfinex API.
19    #[error("failed to build with error: {0}")]
20    FailedToBuild(#[from] reqwest::Error),
21}
22
23/// Errors encountered while fetching data from the Bitfinex API.
24///
25/// These errors can occur during REST API requests to the Bitfinex API,
26/// such as network failures, invalid responses, or data parsing issues.
27#[derive(Debug, Error)]
28pub enum ProviderError {
29    /// Indicates a failure to fetch ticker data from the Bitfinex API.
30    #[error("failed to fetch tickers: {0}")]
31    RequestError(#[from] reqwest::Error),
32
33    /// Indicates that the ticker data contains invalid values (e.g., NaN).
34    #[error("value contains nan")]
35    InvalidValue,
36}