summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-08-02 13:00:30 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-05 10:17:26 +0200
commit24690509898c855409f499f0c81c780602bb0aa7 (patch)
treee7627be920f87e51aea3d136b34632ce9a05096a
parent618a346821b61125ad366faea8ffbb42c62dcbca (diff)
downloadlibnitrokey-24690509898c855409f499f0c81c780602bb0aa7.tar.gz
libnitrokey-24690509898c855409f499f0c81c780602bb0aa7.tar.bz2
Throw exception when retry count is exhausted. Show retry counts in debug messages
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--include/device_proto.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/device_proto.h b/include/device_proto.h
index 6e21f9f..78abe38 100644
--- a/include/device_proto.h
+++ b/include/device_proto.h
@@ -215,11 +215,14 @@ class Transaction : semantics::non_constructible {
Log::instance()("Incoming HID packet:", Loglevel::DEBUG);
Log::instance()((std::string)(resp), Loglevel::DEBUG);
+ Log::instance()(std::string("Retry count: ") + std::to_string(retry), Loglevel::DEBUG);
if (!resp.isValid()) throw std::runtime_error("Invalid incoming packet");
+ if (retry <= 0) throw std::runtime_error("Maximum retry count reached for receiving response from the device!");
if (resp.last_command_status!=0) throw CommandFailedException(resp.command_id, resp.last_command_status);
- // See: DeviceResponse
+
+ // See: DeviceResponse
return resp.payload;
}