From 03f444905d3a7af3091c2401280e83146f08443a Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 31 Jan 2017 18:17:23 +0100 Subject: Add more shortcuts for checking devices error code Signed-off-by: Szczepan Zalega --- include/CommandFailedException.h | 19 ++++++++++++++++--- 1 file 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(cs::timestamp_warning); + } + + bool reason_AES_not_initialized() const throw(){ + return last_command_status == static_cast(cs::AES_dec_failed); + } + + bool reason_not_authorized() const throw(){ + return last_command_status == static_cast(cs::not_authorized); + } + bool reason_slot_not_programmed() const throw(){ return last_command_status == static_cast(cs::slot_not_programmed); } -- cgit v1.2.3