Skip to content

Commit 04e28fd

Browse files
author
Damien LACHAUME / PALO-IT
committed
Add context for open_message db provider calling functions
1 parent c767a21 commit 04e28fd

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

mithril-aggregator/src/services/certifier.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl MithrilCertifierService {
189189
.open_message_repository
190190
.get_open_message_with_single_signatures(signed_entity_type)
191191
.await
192-
.with_context(|| "Can not get open message with single signatures")?;
192+
.with_context(|| "Certifier can not get open message with single signatures for signed entity type: '{signed_entity_type}'")?;
193193

194194
Ok(open_message_with_single_signatures)
195195
}
@@ -199,7 +199,11 @@ impl MithrilCertifierService {
199199
impl CertifierService for MithrilCertifierService {
200200
async fn inform_epoch(&self, epoch: Epoch) -> StdResult<()> {
201201
debug!("CertifierService::inform_epoch(epoch: {epoch:?})");
202-
let nb = self.open_message_repository.clean_epoch(epoch).await?;
202+
let nb = self
203+
.open_message_repository
204+
.clean_epoch(epoch)
205+
.await
206+
.with_context(|| "Certifier can not clean open messages from epoch '{epoch}'")?;
203207
info!("MithrilCertifierService: Informed of a new Epoch: {epoch:?}. Cleaned {nb} open messages along with their single signatures.");
204208

205209
Ok(())
@@ -258,7 +262,7 @@ impl CertifierService for MithrilCertifierService {
258262
.await
259263
.with_context(|| {
260264
format!(
261-
"Can not create open message from protocol_message: '{:?}, epoch: '{}''",
265+
"Certifier can not create open message from protocol_message: '{:?}, epoch: '{}''",
262266
protocol_message,
263267
signed_entity_type.get_epoch()
264268
)
@@ -282,7 +286,7 @@ impl CertifierService for MithrilCertifierService {
282286
.open_message_repository
283287
.get_open_message_with_single_signatures(signed_entity_type)
284288
.await
285-
.with_context(|| "Can not get open message with single signatures")?
289+
.with_context(|| "Certifier can not get open message with single signatures for signed entity type: '{signed_entity_type}'")?
286290
.map(|record| record.into());
287291

288292
Ok(open_message)
@@ -388,7 +392,9 @@ impl CertifierService for MithrilCertifierService {
388392
open_message_certified.is_certified = true;
389393
self.open_message_repository
390394
.update_open_message(&open_message_certified)
391-
.await?;
395+
.await
396+
.with_context(|| "Certifier can not update open message for signed entity type: '{signed_entity_type}'")
397+
?;
392398

393399
Ok(Some(certificate))
394400
}

0 commit comments

Comments
 (0)