Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
26de159415
commit
99ee4fdf43
2 changed files with 5 additions and 2 deletions
|
@ -23,6 +23,7 @@ use libimagstore::storeid::StoreIdIterator;
|
||||||
use crate::notestoreid::*;
|
use crate::notestoreid::*;
|
||||||
use failure::Fallible as Result;
|
use failure::Fallible as Result;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
use failure::ResultExt;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NoteIterator(StoreIdIterator);
|
pub struct NoteIterator(StoreIdIterator);
|
||||||
|
@ -40,11 +41,11 @@ impl Iterator for NoteIterator {
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
while let Some(n) = self.0.next() {
|
while let Some(n) = self.0.next() {
|
||||||
match n {
|
match n.context("Error while iterating").map_err(Error::from) {
|
||||||
Ok(n) => if n.is_note_id() {
|
Ok(n) => if n.is_note_id() {
|
||||||
return Some(Ok(n));
|
return Some(Ok(n));
|
||||||
},
|
},
|
||||||
Err(e) => return Some(Err(e).map_err(Error::from)),
|
Err(e) => return Some(Err(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ use toml_query::set::TomlValueSetExt;
|
||||||
|
|
||||||
use failure::Fallible as Result;
|
use failure::Fallible as Result;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
use failure::ResultExt;
|
||||||
|
|
||||||
pub trait Note {
|
pub trait Note {
|
||||||
fn set_name(&mut self, n: String) -> Result<()>;
|
fn set_name(&mut self, n: String) -> Result<()>;
|
||||||
|
@ -40,6 +41,7 @@ impl Note for Entry {
|
||||||
fn set_name(&mut self, n: String) -> Result<()> {
|
fn set_name(&mut self, n: String) -> Result<()> {
|
||||||
self.get_header_mut()
|
self.get_header_mut()
|
||||||
.set("note.name", Value::String(n))
|
.set("note.name", Value::String(n))
|
||||||
|
.context(format_err!("Cannot set 'note.name' in header of {}", self.get_location()))
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue