Skip to content

Commit 04e4bd5

Browse files
author
Damien LACHAUME / PALO-IT
committed
Add anyhow context for cardano_immutable_files_full
1 parent 0438765 commit 04e4bd5

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use anyhow::Context;
12
use async_trait::async_trait;
23
use semver::Version;
34
use slog_scope::{debug, warn};
@@ -23,8 +24,8 @@ use mithril_common::{
2324
#[derive(Debug, Error)]
2425
pub enum CardanoImmutableFilesFullArtifactError {
2526
/// Protocol message part is missing
26-
#[error("Missing protocol message: '{0}'.")]
27-
MissingProtocolMessage(String),
27+
#[error("Missing protocol message for beacon: '{0}'.")]
28+
MissingProtocolMessage(Beacon),
2829
}
2930

3031
/// A [CardanoImmutableFilesFullArtifact] builder
@@ -62,9 +63,7 @@ impl CardanoImmutableFilesFullArtifactBuilder {
6263
let snapshot_digest = protocol_message
6364
.get_message_part(&ProtocolMessagePartKey::SnapshotDigest)
6465
.ok_or_else(|| {
65-
CardanoImmutableFilesFullArtifactError::MissingProtocolMessage(format!(
66-
"no digest message part found for beacon '{beacon:?}'."
67-
))
66+
CardanoImmutableFilesFullArtifactError::MissingProtocolMessage(beacon.clone())
6867
})?;
6968
let snapshot_name = format!(
7069
"{}-e{}-i{}.{}.{}",
@@ -117,10 +116,9 @@ impl CardanoImmutableFilesFullArtifactBuilder {
117116
.protocol_message
118117
.get_message_part(&ProtocolMessagePartKey::SnapshotDigest)
119118
.ok_or_else(|| {
120-
CardanoImmutableFilesFullArtifactError::MissingProtocolMessage(format!(
121-
"message part 'digest' not found for snapshot '{}'.",
122-
ongoing_snapshot.get_file_path().display()
123-
))
119+
CardanoImmutableFilesFullArtifactError::MissingProtocolMessage(
120+
certificate.beacon.clone(),
121+
)
124122
})?
125123
.to_owned();
126124
let snapshot = Snapshot::new(
@@ -145,8 +143,16 @@ impl ArtifactBuilder<Beacon, Snapshot> for CardanoImmutableFilesFullArtifactBuil
145143
) -> StdResult<Snapshot> {
146144
let ongoing_snapshot = self
147145
.create_snapshot_archive(&beacon, &certificate.protocol_message)
148-
.await?;
149-
let locations = self.upload_snapshot_archive(&ongoing_snapshot).await?;
146+
.await
147+
.with_context(|| {
148+
"Cardano Immutable Files Full Artifact Builder can not create snapshot archive"
149+
})?;
150+
let locations = self
151+
.upload_snapshot_archive(&ongoing_snapshot)
152+
.await
153+
.with_context(|| {
154+
format!("Cardano Immutable Files Full Artifact Builder can not upload snapshot archive to path: '{:?}'", ongoing_snapshot.get_file_path())
155+
})?;
150156

151157
let snapshot = self
152158
.create_snapshot(certificate, &ongoing_snapshot, locations)

0 commit comments

Comments
 (0)