Skip to content

Commit 409e710

Browse files
committed
Use anyhow::Context for better error messages per PR feedback
1 parent f830d6e commit 409e710

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

modules/snapshot_bootstrapper/src/snapshot_bootstrapper.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use acropolis_common::{
1313
stake_addresses::AccountState,
1414
BlockHash, BlockInfo, BlockStatus, Era,
1515
};
16-
use anyhow::Result;
16+
use anyhow::{Result};
1717
use caryatid_sdk::{module, Context, Module};
1818
use config::Config;
1919
use tokio::time::Instant;
@@ -96,16 +96,15 @@ impl SnapshotHandler {
9696
}
9797

9898
async fn publish_start(&self) -> Result<()> {
99-
self.context
99+
anyhow::Context::context(self.context
100100
.message_bus
101101
.publish(
102102
&self.snapshot_topic,
103103
Arc::new(Message::Snapshot(
104104
acropolis_common::messages::SnapshotMessage::Startup,
105105
)),
106106
)
107-
.await
108-
.map_err(|e| anyhow::anyhow!("Failed to publish start message: {e}"))
107+
.await, "Failed to publish start message")
109108
}
110109

111110
async fn publish_completion(
@@ -120,11 +119,10 @@ impl SnapshotHandler {
120119
}),
121120
));
122121

123-
self.context
122+
anyhow::Context::context(self.context
124123
.message_bus
125124
.publish(&self.snapshot_topic, Arc::new(message))
126-
.await
127-
.map_err(|e| anyhow::anyhow!("Failed to publish completion: {e}"))
125+
.await, "Failed to publish completion")
128126
}
129127
}
130128

0 commit comments

Comments
 (0)