diff options
| author | Teddy Wing | 2018-10-21 19:51:48 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-10-21 19:51:48 +0200 | 
| commit | ff244b2e9b7705534ea37ff727be205274ea9ae3 (patch) | |
| tree | a340238898ee00150c8100ecb9640f957ecfd7fb /src/errors.rs | |
| parent | 6b0f1121662e5e9ca968c554bb7a19f6fd5566c9 (diff) | |
| download | dome-key-map-ff244b2e9b7705534ea37ff727be205274ea9ae3.tar.bz2 | |
Add `trial` module, calculate days remaining
This new module will contain functions to calculate trial days.
Here we implement a function to calculate the days remaining in a trial
period.
If there are less than 0 days remaining, it returns an error result.
Couldn't use 'error-chain' because it was complaining about `Debug` and
`PartialEq` not being defined. Don't know if it's possible to implement
those traits on 'error-chain''s ErrorKind`, but it was complicated
enough that I ended up not bothering. Went with 'quick_error' instead to
create a custom error type without having to `impl` all the required
traits.
Diffstat (limited to 'src/errors.rs')
| -rw-r--r-- | src/errors.rs | 10 | 
1 files changed, 10 insertions, 0 deletions
| diff --git a/src/errors.rs b/src/errors.rs index beafc9f..5f09c27 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -5,3 +5,13 @@ error_chain! {          Xdg(xdg::BaseDirectoriesError);      }  } + +quick_error! { +    #[derive(Debug, PartialEq)] +    pub enum DurationError { +        NegativeDuration(duration: i32) { +            description("negative duration") +            display("negative duration: '{}'", duration) +        } +    } +} | 
