aboutsummaryrefslogtreecommitdiffstats
path: root/src/errors.rs
AgeCommit message (Collapse)Author
2018-10-28Add `play_audio()` functionTeddy Wing
Create a new function that encapsulates the code we experimented with for playing audio. Clean up what we had and handle errors by passing them back in a `Result`. This allows us to encapsulate, audio playing so we can do it in a single action during mode switching.
2018-10-23error_chain!::foreign_links: Reorder `ErrorKind` definitionsTeddy Wing
Order them like imports, with `std` errors first, followed by extern crate errors, followed by local errors, alphabetically.
2018-10-23do_trial(): Fix unreachable `DurationError` patternsTeddy Wing
I was getting these warnings: warning: unreachable pattern --> src/trial.rs:41:17 | 40 | DurationError => return trial_expired(), | ------------- matches any value 41 | e => { | ^ unreachable pattern warning: unreachable pattern --> src/trial.rs:55:9 | 54 | DurationError => trial_expired(), | ------------- matches any value 55 | Err(e) => (), | ^^^^^^ unreachable pattern Wasn't correctly matching the `DurationError`s. Add an 'error-chain' `ErrorKind` for `DurationError` to make it the same type as the others matched in the first `match` pattern.
2018-10-22Fill in `get_trial_start()` functionTeddy Wing
Reads the encrypted timestamp from the trial file and returns a `DateTime`.
2018-10-22trial: Add a function to initialise a trial timestamp in a fileTeddy Wing
Save an encoded timestamp to a file. This function should be run once if no trial file is found. The encoded timestamp can then be read on subsequent launches to determine whether the trial period is still in effect. Also add a few function stubs for other actions that seem relevant.
2018-10-22decode_datetime(): Return a `Result`Teddy Wing
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.
2018-10-21Add `trial` module, calculate days remainingTeddy Wing
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.
2018-10-20read_config_file(): Update to get the config from `config.toml`Teddy Wing
Use XDG handling from `state_load_map_group()` to do basically the same thing here for reading the config from a `config.toml` file. Use 'error-chain' to handle the `Result`s more easily. No more nested pattern matching, we'll just have to unwrap one `Result` and write the error to stderr in an FFI function.