diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-04-09 17:27:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-09 17:27:54 +0200 |
commit | 2ccf9bceaafdc24b1eca88288f5045cb69dd1b08 (patch) | |
tree | 9ae6ded3369ccdee0878b86a5319ecaeb66aaae7 /src/error.rs | |
parent | ea9780d1159afda4e4aaf3f7d7ea317b1fd420b7 (diff) | |
parent | d0d8bde43fe1355a740c0f431f7b10f4a2715823 (diff) |
Error cleanup
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/error.rs b/src/error.rs index b9c7b3a..8b01844 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,17 +1,27 @@ -#[derive(Debug, Clone, Eq, PartialEq, Fail)] -pub enum VObjectErrorKind { - #[fail(display = "Parser error: {}", _0)] - ParserError(String), +use thiserror::Error; - #[fail(display = "Not a Vcard")] +use ::parser::ParseErrorReason; + +#[derive(Debug, Clone, Error)] +pub enum VObjectError { + #[error("failed to parse: {}", source)] + Parse { + #[from] + source: ParseErrorReason, + }, + + #[error("Not a Vcard")] NotAVCard, - #[fail(display = "Not a Icalendar: {}", _0)] + #[error("Not a Icalendar: {}", _0)] NotAnICalendar(String), #[cfg(feature = "timeconversions")] - #[fail(display = "{}", _0)] - ChronoError(::chrono::format::ParseError), + #[error("failed to parse time")] + ChronoError { + #[from] + source: chrono::format::ParseError, + }, } -pub type Result<T> = ::std::result::Result<T, VObjectErrorKind>; +pub(crate) type VObjectResult<T> = Result<T, VObjectError>; |