aboutsummaryrefslogtreecommitdiff
path: root/include/CommandFailedException.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-23 15:03:42 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:56 +0200
commit49ea52c45eee26be51df4969ca2af8c2b7c9ceb6 (patch)
tree91c0eb42eeda7286c8b5e83041b71e763f183d2e /include/CommandFailedException.h
parent7eb15813ffa2c2766e53245311b017c3b9c196fb (diff)
downloadlibnitrokey-49ea52c45eee26be51df4969ca2af8c2b7c9ceb6.tar.gz
libnitrokey-49ea52c45eee26be51df4969ca2af8c2b7c9ceb6.tar.bz2
Handling device errors through exceptions
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include/CommandFailedException.h')
-rw-r--r--include/CommandFailedException.h27
1 files changed, 27 insertions, 0 deletions
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 <exception>
+#include <cstdint>
+
+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