Skip to content

Commit b41cdf2

Browse files
Return a PaymentsPollerError instead of box dyn Error in PaymentsPoller
1 parent 315f965 commit b41cdf2

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

aggregation_mode/payments_poller/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async fn main() {
3333
let payments_poller = match PaymentsPoller::new(db, config) {
3434
Ok(poller) => poller,
3535
Err(err) => {
36-
tracing::error!("Failed to create Payments Poller: {err}");
36+
tracing::error!("Failed to create Payments Poller: {err:?}");
3737
return;
3838
}
3939
};

aggregation_mode/payments_poller/src/payments.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ use alloy::{
1111
};
1212
use sqlx::types::BigDecimal;
1313

14+
#[derive(Debug, Clone)]
15+
pub enum PaymentsPollerError {
16+
ReadLastBlockError(String),
17+
}
18+
1419
pub struct PaymentsPoller {
1520
db: Db,
1621
proof_aggregation_service: AggregationModePaymentServiceContract,
@@ -19,7 +24,7 @@ pub struct PaymentsPoller {
1924
}
2025

2126
impl PaymentsPoller {
22-
pub fn new(db: Db, config: Config) -> Result<Self, Box<dyn std::error::Error>> {
27+
pub fn new(db: Db, config: Config) -> Result<Self, PaymentsPollerError> {
2328
let rpc_url = config.eth_rpc_url.parse().expect("RPC URL should be valid");
2429
let rpc_provider = ProviderBuilder::new().connect_http(rpc_url);
2530
let proof_aggregation_service = AggregationModePaymentService::new(
@@ -29,7 +34,9 @@ impl PaymentsPoller {
2934
);
3035

3136
// This check is here to catch early failures on last block fetching
32-
let _ = config.get_last_block_fetched()?;
37+
let _ = config
38+
.get_last_block_fetched()
39+
.map_err(|err| PaymentsPollerError::ReadLastBlockError(err.to_string()));
3340

3441
Ok(Self {
3542
db,

0 commit comments

Comments
 (0)