diff options
| author | Teddy Wing | 2018-10-22 19:33:14 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-10-22 19:33:14 +0200 | 
| commit | 0736dd67d690c597e93324e19126f6c48b81f7c4 (patch) | |
| tree | 57e0343f29a5f97d47353214267e67fa61615fee /src/errors.rs | |
| parent | a709acca8ba41f21e0222debdbe39186c5106beb (diff) | |
| download | dome-key-map-0736dd67d690c597e93324e19126f6c48b81f7c4.tar.bz2 | |
decode_datetime(): Return a `Result`
Make a custom error type because it's trickier to integrate with
'error-chain' given that 'magic-crypt''s `Error` type doesn't implement
the `std::error::Error` trait.
For the same reason, we can't use that as the `cause` for
`DateCryptError::Decrypt`.
This allows us to capture the errors without panicking.
Include some additional cleanups as a result of removing the `use
std::result` and `use errors::*` imports.
Diffstat (limited to 'src/errors.rs')
| -rw-r--r-- | src/errors.rs | 17 | 
1 files changed, 17 insertions, 0 deletions
| diff --git a/src/errors.rs b/src/errors.rs index 5f09c27..c2048e9 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,3 +1,5 @@ +use chrono; +use magic_crypt;  use xdg;  error_chain! { @@ -15,3 +17,18 @@ quick_error! {          }      }  } + +quick_error! { +    #[derive(Debug)] +    pub enum DateCryptError { +        DateParse(err: chrono::format::ParseError) { +            from() +            cause(err) +            display("unable to parse timestamp") +        } +        Decrypt(err: magic_crypt::Error) { +            from() +            display("unable to read trial key") +        } +    } +} | 
