1
+ use anyhow:: Context ;
1
2
use async_trait:: async_trait;
2
3
use semver:: Version ;
3
4
use slog_scope:: { debug, warn} ;
@@ -23,8 +24,8 @@ use mithril_common::{
23
24
#[ derive( Debug , Error ) ]
24
25
pub enum CardanoImmutableFilesFullArtifactError {
25
26
/// 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 ) ,
28
29
}
29
30
30
31
/// A [CardanoImmutableFilesFullArtifact] builder
@@ -62,9 +63,7 @@ impl CardanoImmutableFilesFullArtifactBuilder {
62
63
let snapshot_digest = protocol_message
63
64
. get_message_part ( & ProtocolMessagePartKey :: SnapshotDigest )
64
65
. ok_or_else ( || {
65
- CardanoImmutableFilesFullArtifactError :: MissingProtocolMessage ( format ! (
66
- "no digest message part found for beacon '{beacon:?}'."
67
- ) )
66
+ CardanoImmutableFilesFullArtifactError :: MissingProtocolMessage ( beacon. clone ( ) )
68
67
} ) ?;
69
68
let snapshot_name = format ! (
70
69
"{}-e{}-i{}.{}.{}" ,
@@ -117,10 +116,9 @@ impl CardanoImmutableFilesFullArtifactBuilder {
117
116
. protocol_message
118
117
. get_message_part ( & ProtocolMessagePartKey :: SnapshotDigest )
119
118
. 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
+ )
124
122
} ) ?
125
123
. to_owned ( ) ;
126
124
let snapshot = Snapshot :: new (
@@ -145,8 +143,16 @@ impl ArtifactBuilder<Beacon, Snapshot> for CardanoImmutableFilesFullArtifactBuil
145
143
) -> StdResult < Snapshot > {
146
144
let ongoing_snapshot = self
147
145
. 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
+ } ) ?;
150
156
151
157
let snapshot = self
152
158
. create_snapshot ( certificate, & ongoing_snapshot, locations)
0 commit comments