Skip to content

Commit dc0438f

Browse files
willemoldingnategraf
authored andcommitted
BM-658: Add proper error handling for eth value string parsing failure (#411)
- Addresses silent failure on parsing highlighted in #321 (comment)
1 parent cd61540 commit dc0438f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Diff for: crates/broker/src/bin/broker.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,18 @@ async fn main() -> Result<()> {
3333
CustomRetryPolicy,
3434
);
3535
let client = RpcClient::builder().layer(retry_layer).http(args.rpc_url.clone());
36-
3736
let balance_alerts_layer = BalanceAlertLayer::new(BalanceAlertConfig {
3837
watch_address: wallet.default_signer().address(),
39-
warn_threshold: config.market.balance_warn_threshold.and_then(|s| parse_ether(&s).ok()),
40-
error_threshold: config.market.balance_error_threshold.and_then(|s| parse_ether(&s).ok()),
38+
warn_threshold: config
39+
.market
40+
.balance_warn_threshold
41+
.map(|s| parse_ether(&s))
42+
.transpose()?,
43+
error_threshold: config
44+
.market
45+
.balance_error_threshold
46+
.map(|s| parse_ether(&s))
47+
.transpose()?,
4148
});
4249

4350
let provider = ProviderBuilder::new()

Diff for: crates/broker/src/order_monitor.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@ where
7878
.market
7979
.stake_balance_warn_threshold
8080
.as_ref()
81-
.and_then(|s| parse_ether(s).ok()),
81+
.map(|s| parse_ether(s))
82+
.transpose()?,
8283
&config
8384
.market
8485
.stake_balance_error_threshold
8586
.as_ref()
86-
.and_then(|s| parse_ether(s).ok()),
87+
.map(|s| parse_ether(s))
88+
.transpose()?,
8789
);
8890
}
8991

0 commit comments

Comments
 (0)