From 130a33311567a1f0f6a9a2d8707bff20a558eb20 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 3 Nov 2016 13:45:53 +0100 Subject: Treat LongOperationException as CommandFailed and handle it transparently Signed-off-by: Szczepan Zalega --- include/device_proto.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'include/device_proto.h') diff --git a/include/device_proto.h b/include/device_proto.h index 187d25c..0953566 100644 --- a/include/device_proto.h +++ b/include/device_proto.h @@ -316,21 +316,22 @@ namespace nitrokey { clear_packet(outp); if (status <= 0) - throw std::runtime_error( + throw std::runtime_error( //FIXME replace with CriticalErrorException std::string("Device error while executing command ") + std::to_string(status)); - if (resp.device_status == static_cast(stick10::device_status::busy) && - static_cast(resp.storage_status.device_status) - == stick20::device_status::busy_progressbar){ - throw LongOperationInProgressException(resp.command_id, resp.storage_status.progress_bar_value); - } - Log::instance()("Incoming HID packet:", Loglevel::DEBUG); Log::instance()(static_cast(resp), Loglevel::DEBUG); Log::instance()(std::string("receiving_retry_counter count: ") + std::to_string(receiving_retry_counter), Loglevel::DEBUG); + if (resp.device_status == static_cast(stick10::device_status::busy) && + static_cast(resp.storage_status.device_status) + == stick20::device_status::busy_progressbar){ + throw LongOperationInProgressException( + resp.command_id, resp.device_status, resp.storage_status.progress_bar_value); + } + if (!resp.isValid()) throw std::runtime_error("Invalid incoming packet"); if (receiving_retry_counter <= 0) throw std::runtime_error( -- cgit v1.2.1