summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-05-18 00:14:34 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-05-18 00:54:35 +0200
commit1f9758473822b3ec8dcf4b5b6da56103aca378d2 (patch)
tree732616c870cd4da15f1ef7d1d4ef2535e4f37224
parent741e8acb8aadcb6fe6cf63a3a07570bb9561b3c4 (diff)
downloadimag-1f9758473822b3ec8dcf4b5b6da56103aca378d2.zip
imag-1f9758473822b3ec8dcf4b5b6da56103aca378d2.tar.gz
Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--lib/domain/libimagdiary/src/diary.rs2
-rw-r--r--lib/domain/libimagdiary/src/diaryid.rs3
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/domain/libimagdiary/src/diary.rs b/lib/domain/libimagdiary/src/diary.rs
index 0c447df..b268b0b 100644
--- a/lib/domain/libimagdiary/src/diary.rs
+++ b/lib/domain/libimagdiary/src/diary.rs
@@ -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)
}
diff --git a/lib/domain/libimagdiary/src/diaryid.rs b/lib/domain/libimagdiary/src/diaryid.rs
index bdf9444..c28aebd 100644
--- a/lib/domain/libimagdiary/src/diaryid.rs
+++ b/lib/domain/libimagdiary/src/diaryid.rs
@@ -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)