aboutsummaryrefslogtreecommitdiff
path: root/include/CommandFailedException.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-01-31 18:17:23 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2017-03-11 15:41:41 +0100
commit03f444905d3a7af3091c2401280e83146f08443a (patch)
tree3c055387249adcccb92067457a31fdbaf8e75e42 /include/CommandFailedException.h
parentd69cf0b866fa3cc5afda2bb1a321a900520fbcc1 (diff)
downloadlibnitrokey-03f444905d3a7af3091c2401280e83146f08443a.tar.gz
libnitrokey-03f444905d3a7af3091c2401280e83146f08443a.tar.bz2
Add more shortcuts for checking devices error code
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include/CommandFailedException.h')
-rw-r--r--include/CommandFailedException.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/include/CommandFailedException.h b/include/CommandFailedException.h
index 190eabc..6ff9a2d 100644
--- a/include/CommandFailedException.h
+++ b/include/CommandFailedException.h
@@ -14,11 +14,11 @@ using cs = nitrokey::proto::stick10::command_status;
class CommandFailedException : public std::exception {
public:
- const uint8_t last_command_code;
+ const uint8_t last_command_id;
const uint8_t last_command_status;
- CommandFailedException(uint8_t last_command_code, uint8_t last_command_status) :
- last_command_code(last_command_code),
+ CommandFailedException(uint8_t last_command_id, uint8_t last_command_status) :
+ last_command_id(last_command_id),
last_command_status(last_command_status){
nitrokey::log::Log::instance()(std::string("CommandFailedException, status: ")+ std::to_string(last_command_status), nitrokey::log::Loglevel::DEBUG);
}
@@ -27,6 +27,19 @@ public:
return "Command execution has failed on device";
}
+
+ bool reason_timestamp_warning() const throw(){
+ return last_command_status == static_cast<uint8_t>(cs::timestamp_warning);
+ }
+
+ bool reason_AES_not_initialized() const throw(){
+ return last_command_status == static_cast<uint8_t>(cs::AES_dec_failed);
+ }
+
+ bool reason_not_authorized() const throw(){
+ return last_command_status == static_cast<uint8_t>(cs::not_authorized);
+ }
+
bool reason_slot_not_programmed() const throw(){
return last_command_status == static_cast<uint8_t>(cs::slot_not_programmed);
}