Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
b808658648
commit
5ebbcb774a
2 changed files with 10 additions and 2 deletions
|
@ -18,6 +18,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
use failure::Fallible as Result;
|
use failure::Fallible as Result;
|
||||||
|
use failure::ResultExt;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
|
||||||
use toml::Value;
|
use toml::Value;
|
||||||
|
@ -79,7 +80,12 @@ impl Is for ::libimagstore::store::Entry {
|
||||||
fn is<T: IsKindHeaderPathProvider>(&self) -> Result<bool> {
|
fn is<T: IsKindHeaderPathProvider>(&self) -> Result<bool> {
|
||||||
let field = T::kindflag_header_location();
|
let field = T::kindflag_header_location();
|
||||||
|
|
||||||
match self.get_header().read_bool(field).map_err(Error::from)? {
|
match self
|
||||||
|
.get_header()
|
||||||
|
.read_bool(field)
|
||||||
|
.context(format_err!("Failed reading header '{}' in '{}'", field, self.get_location()))
|
||||||
|
.map_err(Error::from)?
|
||||||
|
{
|
||||||
Some(b) => Ok(b),
|
Some(b) => Ok(b),
|
||||||
None => Ok(false),
|
None => Ok(false),
|
||||||
}
|
}
|
||||||
|
@ -88,6 +94,7 @@ impl Is for ::libimagstore::store::Entry {
|
||||||
fn set_isflag<T: IsKindHeaderPathProvider>(&mut self) -> Result<()> {
|
fn set_isflag<T: IsKindHeaderPathProvider>(&mut self) -> Result<()> {
|
||||||
self.get_header_mut()
|
self.get_header_mut()
|
||||||
.insert(T::kindflag_header_location(), Value::Boolean(true))
|
.insert(T::kindflag_header_location(), Value::Boolean(true))
|
||||||
|
.context(format_err!("Failed inserting header '{}' in '{}'", T::kindflag_header_location(), self.get_location()))
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
@ -96,6 +103,7 @@ impl Is for ::libimagstore::store::Entry {
|
||||||
trace!("Trying to remove: {}", T::kindflag_header_location());
|
trace!("Trying to remove: {}", T::kindflag_header_location());
|
||||||
self.get_header_mut()
|
self.get_header_mut()
|
||||||
.delete(T::kindflag_header_location())
|
.delete(T::kindflag_header_location())
|
||||||
|
.context(format_err!("Failed deleting header '{}' in '{}'", T::kindflag_header_location(), self.get_location()))
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
extern crate filters;
|
extern crate filters;
|
||||||
extern crate toml;
|
extern crate toml;
|
||||||
extern crate toml_query;
|
extern crate toml_query;
|
||||||
extern crate failure;
|
#[macro_use] extern crate failure;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
|
||||||
extern crate libimagstore;
|
extern crate libimagstore;
|
||||||
|
|
Loading…
Reference in a new issue