Skip to content

Commit f85e3a4

Browse files
tanut32039Nattapat IammelapTanut LertwarachaiTanut LertwarachaiRogerKSI
authored
[Feat] Log error detail (#140)
* add band source * run fmt * run clippy * fix band source doc * add band source test * minor fix * fix band config * fix fmt and test * remove unused and refactor code * fix comments * update band source * update proto * format code * add band source config example * add band query command and fix doc * run lint * fix price parse error * fix bitfinex source * run lint * add more error detail * fix comments * fix comment * change from 0.0.1 to 0.1.0 * add test * add default band worker opts * fix log warn debug error * fix comment * add log * fix * refac * fix * fix * lint * refac * patch go-client --------- Co-authored-by: Nattapat Iammelap <nattapat@Nattapats-MacBook-Pro.local> Co-authored-by: Tanut Lertwarachai <tanutlertwarachai@MacBook-Pro.local> Co-authored-by: Tanut Lertwarachai <tanutlertwarachai@Tanuts-MacBook-Pro.local> Co-authored-by: Kitipong Sirirueangsakul <kitipong.sirir@gmail.com>
1 parent a87e2eb commit f85e3a4

File tree

40 files changed

+496
-219
lines changed

40 files changed

+496
-219
lines changed

Cargo.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ resolver = "2"
1717

1818
[workspace.dependencies]
1919
bothan-api = { path = "bothan-api/server" }
20-
bothan-core = { path = "bothan-core", version = "0.0.1" }
21-
bothan-client = { path = "bothan-api/client/rust-client", version = "0.0.1" }
22-
bothan-lib = { path = "bothan-lib", version = "0.0.1" }
20+
bothan-core = { path = "bothan-core", version = "0.1.0" }
21+
bothan-client = { path = "bothan-api/client/rust-client", version = "0.1.0" }
22+
bothan-lib = { path = "bothan-lib", version = "0.1.0" }
2323

24-
bothan-binance = { path = "bothan-binance", version = "0.0.1" }
25-
bothan-bitfinex = { path = "bothan-bitfinex", version = "0.0.1" }
26-
bothan-bybit = { path = "bothan-bybit", version = "0.0.1" }
27-
bothan-coinbase = { path = "bothan-coinbase", version = "0.0.1" }
28-
bothan-coingecko = { path = "bothan-coingecko", version = "0.0.1" }
29-
bothan-coinmarketcap = { path = "bothan-coinmarketcap", version = "0.0.1" }
30-
bothan-htx = { path = "bothan-htx", version = "0.0.1" }
31-
bothan-kraken = { path = "bothan-kraken", version = "0.0.1" }
32-
bothan-okx = { path = "bothan-okx", version = "0.0.1" }
33-
bothan-band = { path = "bothan-band", version = "0.0.1" }
24+
bothan-binance = { path = "bothan-binance", version = "0.1.0" }
25+
bothan-bitfinex = { path = "bothan-bitfinex", version = "0.1.0" }
26+
bothan-bybit = { path = "bothan-bybit", version = "0.1.0" }
27+
bothan-coinbase = { path = "bothan-coinbase", version = "0.1.0" }
28+
bothan-coingecko = { path = "bothan-coingecko", version = "0.1.0" }
29+
bothan-coinmarketcap = { path = "bothan-coinmarketcap", version = "0.1.0" }
30+
bothan-htx = { path = "bothan-htx", version = "0.1.0" }
31+
bothan-kraken = { path = "bothan-kraken", version = "0.1.0" }
32+
bothan-okx = { path = "bothan-okx", version = "0.1.0" }
33+
bothan-band = { path = "bothan-band", version = "0.1.0" }
3434

3535
anyhow = "1.0.86"
3636
async-trait = "0.1.77"

bothan-api-proxy/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module go-proxy
33
go 1.24.2
44

55
require (
6-
github.com/bandprotocol/bothan/bothan-api/client/go-client v0.0.1
6+
github.com/bandprotocol/bothan/bothan-api/client/go-client v0.1.0
77
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0
88
google.golang.org/grpc v1.67.1
99
)

bothan-api/client/rust-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bothan-client"
3-
version = "0.0.1"
3+
version = "0.1.0"
44
description = "Rust client for the Bothan API"
55
authors.workspace = true
66
edition.workspace = true

bothan-api/server-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bothan-api-cli"
3-
version = "0.0.1"
3+
version = "0.1.0"
44
edition.workspace = true
55
license.workspace = true
66
repository.workspace = true

bothan-api/server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bothan-api"
3-
version = "0.0.1"
3+
version = "0.1.0"
44
edition.workspace = true
55
license.workspace = true
66
repository.workspace = true

bothan-api/server/src/api/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
use bothan_core::manager::crypto_asset_info::types::PriceState;
1111
use rust_decimal::prelude::Zero;
12-
use tracing::warn;
12+
use tracing::error;
1313

1414
use crate::api::server::PRECISION;
1515
use crate::proto::bothan::v1::{Price, Status};
@@ -32,7 +32,7 @@ pub fn parse_price_state(id: String, price_state: PriceState) -> Price {
3232
match u64::try_from(mantissa) {
3333
Ok(p) => Price::new(id, p, Status::Available),
3434
Err(_) => {
35-
warn!("failed to convert {mantissa} to u64 for id {id}");
35+
error!("failed to convert {mantissa} to u64 for id {id}");
3636
Price::new(id, 0u64, Status::Unavailable)
3737
}
3838
}

bothan-band/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bothan-band"
3-
version = "0.0.1"
3+
version = "0.1.0"
44
description = "Rust client for the Band source with Bothan integration"
55
edition.workspace = true
66
license.workspace = true

bothan-band/src/api/error.rs

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
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;
67
use 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)]
2728
pub 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)]
3956
pub 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

Comments
 (0)