33//! This module provides custom error types used throughout the Band REST API integration,
44//! particularly for REST API client configuration and concurrent background data fetching.
55
6+ use reqwest:: StatusCode ;
67use thiserror:: Error ;
78
89/// Errors from initializing the Band REST API builder.
@@ -16,7 +17,7 @@ pub enum BuildError {
1617 InvalidURL ( #[ from] url:: ParseError ) ,
1718
1819 /// Represents general failures during HTTP client construction (e.g., TLS configuration issues).
19- #[ error( "reqwest error: {0}" ) ]
20+ #[ error( "failed to build with error: {0}" ) ]
2021 FailedToBuild ( #[ from] reqwest:: Error ) ,
2122}
2223
@@ -26,21 +27,40 @@ pub enum BuildError {
2627#[ derive( Debug , Error ) ]
2728pub enum ProviderError {
2829 /// Indicates HTTP request failure due to network issues or HTTP errors.
29- #[ error( "failed to fetch prices: {0}" ) ]
30- RequestError ( #[ from] reqwest:: Error ) ,
30+ #[ error( "failed to fetch prices (signals={signals}): {error}" ) ]
31+ SendingRequestError {
32+ #[ source]
33+ error : reqwest:: Error ,
34+ signals : String ,
35+ } ,
3136
32- /// Indicates a failure to parse the API response.
33- #[ error( "parse error: {0}" ) ]
34- ParseError ( #[ from] ParseError ) ,
37+ /// Indicates the API returned a non-success HTTP status code.
38+ #[ error( "returned HTTP {status} for signals={signals}: {body}" ) ]
39+ HttpStatusError {
40+ status : StatusCode ,
41+ body : String ,
42+ signals : String ,
43+ } ,
44+
45+ /// Indicates the response body could not be deserialized.
46+ #[ error( "failed to parse response for signals={signals}: {source}" ) ]
47+ ParseResponseError {
48+ #[ source]
49+ source : reqwest:: Error ,
50+ signals : String ,
51+ } ,
3552}
3653
3754/// Errors that can occur while parsing Band API responses.
3855#[ derive( Debug , Error ) ]
3956pub enum ParseError {
40- /// Indicates that the price value is not a valid number (NaN).
41- #[ error( "price is NaN" ) ]
42- InvalidPrice ,
43- /// Indicates that the timestamp value is missing or invalid.
44- #[ error( "invalid timestamp" ) ]
45- InvalidTimestamp ,
57+ /// Indicates that the price field was missing.
58+ #[ error( "missing price from signal {0}" ) ]
59+ MissingPrice ( String ) ,
60+ /// Indicates that the price value is present but not a valid number (NaN/inf).
61+ #[ error( "invalid price value {price} from signal {signal}" ) ]
62+ InvalidPrice { price : f64 , signal : String } ,
63+ /// Indicates that the timestamp field was missing.
64+ #[ error( "missing timestamp from signal {0}" ) ]
65+ MissingTimestamp ( String ) ,
4666}
0 commit comments