diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-02 13:00:30 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-05 10:17:26 +0200 |
commit | 24690509898c855409f499f0c81c780602bb0aa7 (patch) | |
tree | e7627be920f87e51aea3d136b34632ce9a05096a /include/device_proto.h | |
parent | 618a346821b61125ad366faea8ffbb42c62dcbca (diff) | |
download | libnitrokey-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>
Diffstat (limited to 'include/device_proto.h')
-rw-r--r-- | include/device_proto.h | 5 |
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; } |