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 f44e10e295
commit d8bcb8ca8e
2 changed files with 5 additions and 1 deletions

View file

@ -23,6 +23,7 @@ use toml_query::read::TomlValueReadExt;
use filters::failable::filter::FailableFilter;
use failure::Fallible as Result;
use failure::ResultExt;
use failure::Error;
use crate::builtin::header::field_path::FieldPath;
@ -47,6 +48,9 @@ impl FailableFilter<Entry> for FieldExists {
fn filter(&self, e: &Entry) -> Result<bool> {
e.get_header()
.read(&self.header_field_path[..])
.context(format_err!("Failed reading header '{}' in '{}'",
self.header_field_path,
e.get_location()))
.map_err(Error::from)
.map(|o| o.is_some())
}

View file

@ -40,7 +40,7 @@ extern crate regex;
extern crate semver;
extern crate toml;
extern crate toml_query;
extern crate failure;
#[macro_use] extern crate failure;
extern crate libimagstore;
extern crate libimagentrytag;