Skip to content

Commit

Permalink
286 add blob path to error context (#287)
Browse files Browse the repository at this point in the history
* [286] Add file path to error context

* [286] Update changelog
  • Loading branch information
ikopylov authored Jun 5, 2023
1 parent 2c4f07d commit 1634487
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Pearl changelog
#### Added

#### Changed
- Blob file path added into context information for several errors (#286)

#### Fixed

Expand Down
18 changes: 10 additions & 8 deletions src/blob/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ impl<K: Key + 'static> Blob<K> {
} else {
self.fsyncdata()
.await
.with_context(|| "Blob file dump failed!")?;
.with_context(|| format!("blob file dump failed: {:?}", self.name.to_path().display()))?;
self.index
.dump()
.await
.with_context(|| "Blob index file dump failed!")
.with_context(|| format!("index file dump failed, associated blob file: {:?}", self.name.to_path().display()))
}
}

Expand Down Expand Up @@ -119,7 +119,7 @@ impl<K: Key + 'static> Blob<K> {

let header = Header::from_file(&name, ioring.clone())
.await
.context("failed to read blob header")?;
.with_context(|| format!("failed to read blob header. Blob file: {}", path.display()))?;

let mut index_name = name.clone();
index_name.extension = BLOB_INDEX_FILE_EXTENSION.to_owned();
Expand All @@ -133,7 +133,7 @@ impl<K: Key + 'static> Blob<K> {
if let Some(io_error) = error.downcast_ref::<IOError>() {
match io_error.kind() {
IOErrorKind::PermissionDenied | IOErrorKind::Other => {
warn!("index cannot be regenerated due to error: {}", io_error);
warn!("index for file '{}' cannot be regenerated due to an error: {}", path.display(), io_error);
return Err(error);
}
_ => {}
Expand Down Expand Up @@ -161,7 +161,7 @@ impl<K: Key + 'static> Blob<K> {
if is_index_corrupted || size as u64 > header_size {
blob.try_regenerate_index()
.await
.context("failed to regenerate index")?;
.with_context(|| format!("failed to regenerate index for blob file: {}", path.display()))?;
} else {
warn!("empty or corrupted blob: {:?}", path);
}
Expand Down Expand Up @@ -195,7 +195,7 @@ impl<K: Key + 'static> Blob<K> {
let raw_r = self
.raw_records()
.await
.context("failed to read raw records")?;
.with_context(|| format!("failed to read raw records from blob {}", self.name.to_path().display()))?;
debug!("raw records loaded");
if let Some(headers) = raw_r.load().await.with_context(|| {
format!(
Expand Down Expand Up @@ -254,7 +254,7 @@ impl<K: Key + 'static> Blob<K> {
let buf = entry
.load()
.await
.with_context(|| format!("failed to read key {:?} with meta {:?}", key, meta))?
.with_context(|| format!("failed to read key {:?} with meta {:?} from blob {}", key, meta, self.name.to_path().display()))?
.into_data();
debug!("blob read any entry loaded bytes: {}", buf.len());
Ok(buf)
Expand Down Expand Up @@ -313,7 +313,9 @@ impl<K: Key + 'static> Blob<K> {
.index
.get_any(key)
.await
.with_context(|| "blob index get any failed")?
.with_context(|| {
format!("index get any failed for blob: {}", self.name.to_path().display())
})?
{
let entry = Entry::new(header, self.file.clone());
debug!("blob, get any entry, bloom true no meta, entry found");
Expand Down

0 comments on commit 1634487

Please sign in to comment.