aboutsummaryrefslogtreecommitdiff
path: root/include/device_proto.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/device_proto.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/device_proto.h')
-rw-r--r--include/device_proto.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/device_proto.h b/include/device_proto.h
index 79632d9..2bbb38a 100644
--- a/include/device_proto.h
+++ b/include/device_proto.h
@@ -14,6 +14,7 @@
#include "log.h"
#include "command_id.h"
#include "dissect.h"
+#include "CommandFailedException.h"
#define STICK20_UPDATE_MODE_VID 0x03EB
#define STICK20_UPDATE_MODE_PID 0x2FF1
@@ -212,6 +213,7 @@ class Transaction : semantics::non_constructible {
Log::instance()((std::string)(resp), Loglevel::DEBUG);
if (!resp.isValid()) throw std::runtime_error("Invalid incoming packet");
+ if (resp.last_command_status!=0) throw CommandFailedException(resp.command_id, resp.last_command_status);
// See: DeviceResponse
return resp.payload;