From 385d33bb4c8bb7fe604f5e0acc8aeca5f2146fae Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 25 Oct 2016 18:40:30 +0200 Subject: Handle busy_progressbar device status Signed-off-by: Szczepan Zalega --- include/LongOperationInProgressException.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 include/LongOperationInProgressException.h (limited to 'include/LongOperationInProgressException.h') diff --git a/include/LongOperationInProgressException.h b/include/LongOperationInProgressException.h new file mode 100644 index 0000000..673a218 --- /dev/null +++ b/include/LongOperationInProgressException.h @@ -0,0 +1,28 @@ +// +// Created by sz on 24.10.16. +// + +#ifndef LIBNITROKEY_LONGOPERATIONINPROGRESSEXCEPTION_H +#define LIBNITROKEY_LONGOPERATIONINPROGRESSEXCEPTION_H + + +class LongOperationInProgressException : public std::exception { + +public: + unsigned char progress_bar_value; + unsigned char command_id; + + LongOperationInProgressException(unsigned char _command_id, unsigned char _progress_bar_value) { + command_id = _command_id; + progress_bar_value = _progress_bar_value; + nitrokey::log::Log::instance()( + std::string("LongOperationInProgressException, progress bar status: ")+ + std::to_string(progress_bar_value), nitrokey::log::Loglevel::DEBUG); + } + virtual const char *what() const throw() { + return "Device returned busy status with long operation in progress"; + } +}; + + +#endif //LIBNITROKEY_LONGOPERATIONINPROGRESSEXCEPTION_H -- cgit v1.2.1 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/LongOperationInProgressException.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include/LongOperationInProgressException.h') diff --git a/include/LongOperationInProgressException.h b/include/LongOperationInProgressException.h index 673a218..7f182b0 100644 --- a/include/LongOperationInProgressException.h +++ b/include/LongOperationInProgressException.h @@ -5,16 +5,16 @@ #ifndef LIBNITROKEY_LONGOPERATIONINPROGRESSEXCEPTION_H #define LIBNITROKEY_LONGOPERATIONINPROGRESSEXCEPTION_H +#include "CommandFailedException.h" -class LongOperationInProgressException : public std::exception { +class LongOperationInProgressException : public CommandFailedException { public: unsigned char progress_bar_value; - unsigned char command_id; - LongOperationInProgressException(unsigned char _command_id, unsigned char _progress_bar_value) { - command_id = _command_id; - progress_bar_value = _progress_bar_value; + LongOperationInProgressException( + unsigned char _command_id, uint8_t last_command_status, unsigned char _progress_bar_value) + : CommandFailedException(_command_id, last_command_status), progress_bar_value(_progress_bar_value){ nitrokey::log::Log::instance()( std::string("LongOperationInProgressException, progress bar status: ")+ std::to_string(progress_bar_value), nitrokey::log::Loglevel::DEBUG); -- cgit v1.2.1