From 24690509898c855409f499f0c81c780602bb0aa7 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 2 Aug 2016 13:00:30 +0200 Subject: Throw exception when retry count is exhausted. Show retry counts in debug messages Signed-off-by: Szczepan Zalega --- include/device_proto.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') 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; } -- cgit v1.2.3