~matthiasbeyer/imag

c7ea58eda2c90800804554e431a375b08da409c5 — Matthias Beyer 1 year, 11 months ago d8bcb8c
Add more context in error messages

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2 files changed, 8 insertions(+), 3 deletions(-)

M lib/entry/libimagentrygps/src/entry.rs
M lib/entry/libimagentrygps/src/lib.rs
M lib/entry/libimagentrygps/src/entry.rs => lib/entry/libimagentrygps/src/entry.rs +7 -2
@@ 60,11 60,16 @@ impl GPSEntry for Entry {
        self.get_header_mut()
            .insert("gps.coordinates", c.into())
            .map(|_| ())
            .context(format_err!("Error while inserting header 'gps.coordinates' in '{}'", self.get_location()))
            .map_err(Error::from)
    }

    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),
            None      => Ok(None),
        }


@@ 89,7 94,7 @@ impl GPSEntry for Entry {
        let hdr = self.get_header_mut();
        for pattern in patterns.iter() {
            let _ = hdr.delete(pattern)
                .map_err(Error::from)
                .context(format_err!("Error while deleting header '{}'", pattern))
                .context("Error writing header")?;
        }


M lib/entry/libimagentrygps/src/lib.rs => lib/entry/libimagentrygps/src/lib.rs +1 -1
@@ 38,7 38,7 @@
extern crate toml;
extern crate toml_query;
#[macro_use] extern crate serde_derive;
extern crate failure;
#[macro_use] extern crate failure;

extern crate libimagstore;
extern crate libimagerror;