From 49ea52c45eee26be51df4969ca2af8c2b7c9ceb6 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Sat, 23 Jul 2016 15:03:42 +0200 Subject: Handling device errors through exceptions Signed-off-by: Szczepan Zalega --- include/CommandFailedException.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 include/CommandFailedException.h (limited to 'include/CommandFailedException.h') diff --git a/include/CommandFailedException.h b/include/CommandFailedException.h new file mode 100644 index 0000000..3306f7b --- /dev/null +++ b/include/CommandFailedException.h @@ -0,0 +1,27 @@ +// +// Created by sz on 23.07.16. +// + +#ifndef LIBNITROKEY_COMMANDFAILEDEXCEPTION_H +#define LIBNITROKEY_COMMANDFAILEDEXCEPTION_H + +#include +#include + +class CommandFailedException : public std::exception { +public: + uint8_t last_command_code; + uint8_t last_command_status; + + CommandFailedException(uint8_t last_command_code, uint8_t last_command_status) : + last_command_code(last_command_code), + last_command_status(last_command_status){} + + virtual const char *what() const throw() { + return "Command execution has failed on device"; + } + +}; + + +#endif //LIBNITROKEY_COMMANDFAILEDEXCEPTION_H -- cgit v1.2.1