Skip to content

Commit

Permalink
Add ParseError to Error enum
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Dec 12, 2019
1 parent e53ca14 commit 6913768
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::format::ParseError;
use core::fmt;

/// A unified error type for anything returned by a method in the time crate.
Expand All @@ -10,6 +11,7 @@ use core::fmt;
pub enum Error {
ConversionRange(ConversionRangeError),
ComponentRange(ComponentRangeError),
Parse(ParseError),
}

impl fmt::Display for Error {
Expand All @@ -18,6 +20,7 @@ impl fmt::Display for Error {
match self {
Self::ConversionRange(e) => e.fmt(f),
Self::ComponentRange(e) => e.fmt(f),
Self::Parse(e) => e.fmt(f),
}
}
}
Expand Down Expand Up @@ -71,3 +74,10 @@ impl From<ComponentRangeError> for Error {

#[cfg(feature = "std")]
impl std::error::Error for ComponentRangeError {}

impl From<ParseError> for Error {
#[inline(always)]
fn from(original: ParseError) -> Self {
Self::Parse(original)
}
}

0 comments on commit 6913768

Please sign in to comment.