diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-02-02 19:43:01 +0100 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2021-02-02 19:43:01 +0100 |
commit | 5cc24a7df2ca39e1c35e98c71bc875b3cdd8cce1 (patch) | |
tree | 6cdd13f1c206b6f6a5924c329f96731554bee803 /src | |
parent | e5c852291fc1368f9286310b55be22c2ee9e80e3 (diff) |
Add more error context information
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/package/source.rs | 18 | ||||
-rw-r--r-- | src/source/mod.rs | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/package/source.rs b/src/package/source.rs index 773b0a5..42cfa28 100644 --- a/src/package/source.rs +++ b/src/package/source.rs @@ -9,6 +9,7 @@ // use anyhow::anyhow; +use anyhow::Context; use anyhow::Result; use getset::Getters; use log::trace; @@ -52,7 +53,10 @@ pub struct SourceHash { impl SourceHash { pub async fn matches_hash_of<R: tokio::io::AsyncRead + Unpin>(&self, reader: R) -> Result<()> { trace!("Hashing buffer with: {:?}", self.hashtype); - let h = self.hashtype.hash_from_reader(reader).await?; + let h = self.hashtype + .hash_from_reader(reader) + .await + .context("Hashing failed")?; trace!("Hashing buffer with: {} finished", self.hashtype); if h == self.value { @@ -101,7 +105,9 @@ impl HashType { let mut m = sha1::Sha1::new(); loop { trace!("Reading"); - let count = reader.read(&mut buffer).await?; + let count = reader.read(&mut buffer) + .await + .context("Reading buffer failed")?; trace!("Read {} bytes", count); if count == 0 { @@ -119,7 +125,9 @@ impl HashType { let mut m = sha2::Sha256::new(); loop { trace!("Reading"); - let count = reader.read(&mut buffer).await?; + let count = reader.read(&mut buffer) + .await + .context("Reading buffer failed")?; trace!("Read {} bytes", count); if count == 0 { @@ -137,7 +145,9 @@ impl HashType { let mut m = sha2::Sha512::new(); loop { trace!("Reading"); - let count = reader.read(&mut buffer).await?; + let count = reader.read(&mut buffer) + .await + .context("Reading buffer failed")?; trace!("Read {} bytes", count); if count == 0 { diff --git a/src/source/mod.rs b/src/source/mod.rs index bebd68a..ec0e2e2 100644 --- a/src/source/mod.rs +++ b/src/source/mod.rs @@ -107,7 +107,8 @@ impl SourceEntry { .read(true) .open(&p) .await - .map(tokio::io::BufReader::new)?; + .map(tokio::io::BufReader::new) + .context("Opening file failed")?; trace!("Reader constructed for path: {}", p.display()); self.package_source |