Skip to content

Commit

Permalink
chore: log detailed intermediate errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Nov 1, 2023
1 parent 5a622f5 commit 1e600ec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion sn_client/src/file_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ impl Files {
downloaded_file_path: Option<PathBuf>,
show_holders: bool,
) -> Result<Option<Bytes>> {
let chunk = self.client.get_chunk(address, show_holders).await?;
let chunk = match self.client.get_chunk(address, show_holders).await {
Ok(chunk) => chunk,
Err(err) => {
error!("Failed to fetch head chunk {address:?}");
return Err(err);
}
};

// first try to deserialize a LargeFile, if it works, we go and seek it
if let Ok(data_map) = self.unpack_chunk(chunk.clone()).await {
Expand Down
1 change: 1 addition & 0 deletions sn_networking/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ impl SwarmDriver {
// A claimed Chunk type record can be trusted.
// Punishment of peer that sending corrupted Chunk type record
// maybe carried out by other verification mechanism.
let _ = sender.send(Ok(peer_record.record.clone()));
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions sn_networking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ impl Network {
expected_holders: expected_holders.clone(),
})?;

match receiver
.await
.map_err(|_e| Error::InternalMsgChannelDropped)?
{
match receiver.await.map_err(|e| {
error!("When fetching record {pretty_key:?} , encountered a channel error {e:?}.");
Error::InternalMsgChannelDropped
})? {
Ok(returned_record) => {
let header = RecordHeader::from_record(&returned_record)?;
let is_chunk = matches!(header.kind, RecordKind::Chunk);
Expand Down

0 comments on commit 1e600ec

Please sign in to comment.