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 741e8acb8a
commit 1f97584738
2 changed files with 5 additions and 0 deletions

View File

@ -30,6 +30,7 @@ use itertools::Itertools;
use chrono::naive::NaiveDateTime;
use chrono::Timelike;
use failure::Fallible as Result;
use failure::ResultExt;
use failure::Error;
use crate::entry::IsDiaryEntry;
@ -141,6 +142,7 @@ impl Diary for Store {
fn diary_names(&self) -> Result<DiaryNameIterator> {
self.entries()
.map(|it| DiaryNameIterator::new(it.into_storeid_iter()))
.context("Failed building DiaryNameIteator from entries iterator")
.map_err(Error::from)
}

View File

@ -234,6 +234,7 @@ impl FromStoreId for DiaryId {
let day: Result<u32> = next_component(&mut cmps)
.and_then(|s| {
s.parse::<u32>()
.context("Failed to parse day from u32")
.map_err(Error::from)
.context(err_msg("ID parse error"))
.map_err(Error::from)
@ -242,6 +243,7 @@ impl FromStoreId for DiaryId {
let month: Result<u32> = next_component(&mut cmps)
.and_then(|s| {
s.parse::<u32>()
.context("Failed to parse month from u32")
.map_err(Error::from)
.context(err_msg("ID Parse error"))
.map_err(Error::from)
@ -250,6 +252,7 @@ impl FromStoreId for DiaryId {
let year: Result<i32> = next_component(&mut cmps)
.and_then(|s| {
s.parse::<i32>()
.context("Failed to parse year from i32")
.map_err(Error::from)
.context(err_msg("ID Parse error"))
.map_err(Error::from)