summaryrefslogtreecommitdiff
path: root/include/CommandFailedException.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-01-17 15:35:44 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2017-03-11 15:41:39 +0100
commit56bd3e2c4353cfc1b902c6dfb55df0ef563c5372 (patch)
tree0bd187ba6637222278f76b7b9d711aa758a67f4a /include/CommandFailedException.h
parentc551b27792774b87a1be7fd0dcfd9e209eaef5ec (diff)
downloadlibnitrokey-56bd3e2c4353cfc1b902c6dfb55df0ef563c5372.tar.gz
libnitrokey-56bd3e2c4353cfc1b902c6dfb55df0ef563c5372.tar.bz2
Check command's fail reason within exception
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include/CommandFailedException.h')
-rw-r--r--include/CommandFailedException.h9
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);
}
};