diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-03-05 19:48:58 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-03-05 19:48:58 +0100 |
commit | 07f108e1d25da387735ce2ddca04a768a2739d9f (patch) | |
tree | 3b19df5d2c22d8954b446f22f014e50dea33876a /src/parser/timetype.rs | |
parent | 0b9130fd4e0a85e9603f2eee4678a6326aaf87c4 (diff) |
Replace failure with thiserror
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/parser/timetype.rs')
-rw-r--r-- | src/parser/timetype.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/parser/timetype.rs b/src/parser/timetype.rs index 13f111b..1437242 100644 --- a/src/parser/timetype.rs +++ b/src/parser/timetype.rs @@ -4,11 +4,11 @@ use std::str::FromStr; use nom::digit; use nom::whitespace::sp; use chrono::NaiveDate; -use failure::Fallible as Result; use timetype::IntoTimeType; use timetype; -use error::ErrorKind as KEK; +use error::Result; +use error::Error; named!(pub integer<i64>, alt!( map_res!( @@ -192,12 +192,12 @@ impl IntoTimeType for ExactDate { ExactDate::Iso8601Date(date) => { match date { ::iso8601::Date::YMD { year, month, day } => NaiveDate::from_ymd_opt(year, month, day) - .ok_or(KEK::OutOfBounds(year, month, day, 0, 0, 0).into()) + .ok_or(Error::OutOfBounds(year, month, day, 0, 0, 0)) .map(|ndt| ndt.and_hms(0, 0, 0)) .map(timetype::TimeType::moment), ::iso8601::Date::Week { year, ww, d } => NaiveDate::from_ymd_opt(year, 1, 1) - .ok_or(KEK::OutOfBounds(year, 1, 1, 0, 0, 0).into()) + .ok_or(Error::OutOfBounds(year, 1, 1, 0, 0, 0)) .map(|ndt| ndt.and_hms(0, 0, 0)) .map(timetype::TimeType::moment) .map(|m| { @@ -207,7 +207,7 @@ impl IntoTimeType for ExactDate { }), ::iso8601::Date::Ordinal { year, ddd } => NaiveDate::from_ymd_opt(year, 1, 1) - .ok_or(KEK::OutOfBounds(year, 1, 1, 0, 0, 0).into()) + .ok_or(Error::OutOfBounds(year, 1, 1, 0, 0, 0)) .map(|ndt| ndt.and_hms(0, 0, 0)) .map(timetype::TimeType::moment) .map(|m| m + timetype::TimeType::days(ddd as i64)), @@ -219,11 +219,11 @@ impl IntoTimeType for ExactDate { match date { ::iso8601::Date::YMD { year, month, day } => NaiveDate::from_ymd_opt(year, month, day) .and_then(|ndt| ndt.and_hms_opt(hour, minute, second)) - .ok_or(KEK::OutOfBounds(year, month, day, hour, minute, second).into()) + .ok_or(Error::OutOfBounds(year, month, day, hour, minute, second)) .map(timetype::TimeType::moment), ::iso8601::Date::Week { year, ww, d } => NaiveDate::from_ymd_opt(year, 1, 1) - .ok_or(KEK::OutOfBounds(year, 1, 1, 0, 0, 0).into()) + .ok_or(Error::OutOfBounds(year, 1, 1, 0, 0, 0)) .map(|ndt| ndt.and_hms(0, 0, 0)) .map(timetype::TimeType::moment) .map(|m| { @@ -236,7 +236,7 @@ impl IntoTimeType for ExactDate { }), ::iso8601::Date::Ordinal { year, ddd } => NaiveDate::from_ymd_opt(year, 1, 1) - .ok_or(KEK::OutOfBounds(year, 1, 1, 0, 0, 0).into()) + .ok_or(Error::OutOfBounds(year, 1, 1, 0, 0, 0)) .map(|ndt| ndt.and_hms(0, 0, 0)) .map(timetype::TimeType::moment) .map(|m| { |