From 56bd3e2c4353cfc1b902c6dfb55df0ef563c5372 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 17 Jan 2017 15:35:44 +0100 Subject: Check command's fail reason within exception Signed-off-by: Szczepan Zalega --- include/CommandFailedException.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') 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 #include #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(cs::slot_not_programmed); + } + + bool reason_wrong_password() const throw(){ + return last_command_status == static_cast(cs::wrong_password); } }; -- cgit v1.2.1