aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
Commit message (Collapse)AuthorAge
* Introduce the Error::UnexpectedError variantRobin Krahl2019-01-20
| | | | | | | The UnexpectedError variant is used when a libnitrokey function returns a value that violates the function’s contract, for example if a function returns a null pointer although it guarantees to never return null. Previously, we returned a CommandError::Unspecified in these cases.
* Make CommandError messages more generalRobin Krahl2019-01-20
| | | | For example, the WrongSlot error may also be returned for a PWS slot.
* Remove CommandError::as_str methodRobin Krahl2019-01-20
| | | | | AsStr is automatically implementeded if Display is implemented, so having a manual as_str() method is not necessary.
* Add the CommunicationError enumRobin Krahl2019-01-20
| | | | | | Communication errors returned by libnitrokey were previously not mapped to an error type in the nitrokey crate. We introduce the CommunicationError enum to represent these errors.
* Refactor library errors into LibraryError enumRobin Krahl2019-01-20
| | | | | | Previously, library errors were part of the CommandError enum. As command errors and library errors are two different error types, they should be split into two enums.
* Move the CommandError::Unknown to ErrorRobin Krahl2019-01-20
| | | | | | | An error code can not only indiciate a command error, but also a library or device communication error. Therefore, the variant for an unknown error code should be placed in the top-level Error enum instead of the CommandError enum.
* Refactor CommandError::RngError into Error::RandErrorRobin Krahl2019-01-20
| | | | | We reserve CommandError for errors returned by the Nitrokey device. Errors during random number generation should have their own type.
* Return Error instead of CommandErrorRobin Krahl2019-01-20
| | | | | | | | | | This patch changes all public functions to return the Error enum instead of the CommandError enum. This breaks the tests which will be fixed with the next patch. This patch also adds a placeholder variant Error::CommandError and a placeholder enum CommandError to make the transition to a new nitrokey-test version easier.
* Add the Error enum and the Result<T> typedefRobin Krahl2019-01-20
| | | | | The Error enum is a wrapper for the possible error types (currently only CommandError). Result<T> is defined as Result<T, Error>.
* Implement std::error::Error for error::CommandErrorRobin Krahl2019-01-20
|
* Move util::CommandError to the new error moduleRobin Krahl2019-01-20
This prepares the refactoring of util::CommandError into multiple enums.