Add more context in error messages

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-05-18 00:14:34 +02:00
parent d8bcb8ca8e
commit c7ea58eda2
2 changed files with 8 additions and 3 deletions

View file

@ -60,11 +60,16 @@ impl GPSEntry for Entry {
self.get_header_mut() self.get_header_mut()
.insert("gps.coordinates", c.into()) .insert("gps.coordinates", c.into())
.map(|_| ()) .map(|_| ())
.context(format_err!("Error while inserting header 'gps.coordinates' in '{}'", self.get_location()))
.map_err(Error::from) .map_err(Error::from)
} }
fn get_coordinates(&self) -> Result<Option<Coordinates>> { fn get_coordinates(&self) -> Result<Option<Coordinates>> {
match self.get_header().read("gps.coordinates").map_err(Error::from)? { match self
.get_header()
.read("gps.coordinates")
.context(format_err!("Error while reading header 'gps.coordinates' in '{}'", self.get_location()))?
{
Some(hdr) => Coordinates::from_value(hdr).map(Some), Some(hdr) => Coordinates::from_value(hdr).map(Some),
None => Ok(None), None => Ok(None),
} }
@ -89,7 +94,7 @@ impl GPSEntry for Entry {
let hdr = self.get_header_mut(); let hdr = self.get_header_mut();
for pattern in patterns.iter() { for pattern in patterns.iter() {
let _ = hdr.delete(pattern) let _ = hdr.delete(pattern)
.map_err(Error::from) .context(format_err!("Error while deleting header '{}'", pattern))
.context("Error writing header")?; .context("Error writing header")?;
} }

View file

@ -38,7 +38,7 @@
extern crate toml; extern crate toml;
extern crate toml_query; extern crate toml_query;
#[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_derive;
extern crate failure; #[macro_use] extern crate failure;
extern crate libimagstore; extern crate libimagstore;
extern crate libimagerror; extern crate libimagerror;