summaryrefslogtreecommitdiff
path: root/src/error.rs
Commit message (Collapse)AuthorAge
* Rename Error::Unknown to Error::UnknownErrorRobin Krahl2019-01-27
| | | | | For consistency with the other Error variants, we rename Unknown to UnknownError.
* Remove the Result typedefRobin Krahl2019-01-27
| | | | | | | | | Many of our functions do not return a Result<_, Error>, but for example a Result<_, (Device, Error)>. We only use the typedef in one function, but it makes the other functions more complicated as we have to use result::Result (if crate::Result is imported). Therefore, this patch removes the typedef. Applications or libraries can still redefine it if they want to.
* Remove rand_core::Error from public APIRobin Krahl2019-01-25
| | | | | | | rand_core does not have a stable release yet, and it is unlikely that there will be one soon. To be able to stabilize nitrokey without waiting for a stable rand_core version, we remove the rand_core::Error type from the public API and replace it with a Box<dyn error::Error>.
* Add license and copyright informationRobin Krahl2019-01-23
| | | | | | | This patch adds license and copyright information to all files to make nitrokey-rs compliant with the REUSE practices [0]. [0] https://reuse.software/practices/2.0/
* Implement From<(T: Device, Error)> for ErrorRobin Krahl2019-01-23
| | | | | | Not all users of the authenticate methods want to use the device after an error, so implementing From<(T: Device, Error)> for Error makes it easier for them to discard the device.
* Add Error::Utf8Error variantRobin Krahl2019-01-23
| | | | | Previously, we just ignored UTF-8 errors. This patch prepares the Utf8Error variant so that we are able to return UTF-8 errors.
* Remove the unused CommandError::Undefined variantRobin Krahl2019-01-20
| | | | | | The CommandError::Undefined variant has been refactored into Error::UnexpectedError and CommunicationError::NotConnected and is therefore no longer needed.
* 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.