diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-01-17 15:35:44 +0100 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2017-03-11 15:41:39 +0100 |
commit | 56bd3e2c4353cfc1b902c6dfb55df0ef563c5372 (patch) | |
tree | 0bd187ba6637222278f76b7b9d711aa758a67f4a | |
parent | c551b27792774b87a1be7fd0dcfd9e209eaef5ec (diff) | |
download | libnitrokey-56bd3e2c4353cfc1b902c6dfb55df0ef563c5372.tar.gz libnitrokey-56bd3e2c4353cfc1b902c6dfb55df0ef563c5372.tar.bz2 |
Check command's fail reason within exception
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r-- | include/CommandFailedException.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/CommandFailedException.h b/include/CommandFailedException.h index 3753ad4..190eabc 100644 --- a/include/CommandFailedException.h +++ b/include/CommandFailedException.h @@ -8,6 +8,9 @@ #include <exception> #include <cstdint> #include "log.h" +#include "command_id.h" + +using cs = nitrokey::proto::stick10::command_status; class CommandFailedException : public std::exception { public: @@ -25,7 +28,11 @@ public: } bool reason_slot_not_programmed() const throw(){ - return last_command_status == 3; //FIXME use enum status codes + return last_command_status == static_cast<uint8_t>(cs::slot_not_programmed); + } + + bool reason_wrong_password() const throw(){ + return last_command_status == static_cast<uint8_t>(cs::wrong_password); } }; |