From a216a1bda137363be47449c0d4de413778906415 Mon Sep 17 00:00:00 2001 From: Pawel Andruszkiewicz Date: Fri, 27 Nov 2015 15:01:14 +0100 Subject: [PATCH] [SecureElement] Log refactoring. [Verification] Not tested, module disabled. Change-Id: I713402f563dc7665ca87a17433541ec5e89f1f12 Signed-off-by: Pawel Andruszkiewicz --- src/secureelement/secureelement_instance.cc | 60 +++++++------------- src/secureelement/secureelement_seservice.cc | 6 +- 2 files changed, 23 insertions(+), 43 deletions(-) diff --git a/src/secureelement/secureelement_instance.cc b/src/secureelement/secureelement_instance.cc index e486668f..6b3f537d 100644 --- a/src/secureelement/secureelement_instance.cc +++ b/src/secureelement/secureelement_instance.cc @@ -165,20 +165,15 @@ void SecureElementInstance::OpenSession( picojson::value result = seReader.openSession(); ReportSuccess(result, response->get()); } catch (const ErrorIO& err) { - LoggerD("Library reported ErrorIO!"); - ReportError(PlatformResult(ErrorCode::IO_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::IO_ERR), &response->get()); } catch (const ErrorIllegalState& err) { - LoggerD("Library reported ErrorIllegalState!"); - ReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get()); } catch (const ErrorIllegalParameter& err) { - LoggerD("Library reported ErrorIllegalParameter!"); - ReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get()); } catch (const ErrorSecurity& err) { - LoggerD("Library reported ErrorSecurity!"); - ReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get()); } catch (const ExceptionBase& err) { - LoggerD("Library reported ExceptionBase!"); - ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get()); } }; @@ -213,20 +208,15 @@ void SecureElementInstance::OpenBasicChannel( const picojson::value& args, picoj picojson::value result = seSession.openBasicChannel(v_aid); ReportSuccess(result, response->get()); } catch (const ErrorIO& err) { - LoggerD("Library reported ErrorIO!"); - ReportError(PlatformResult(ErrorCode::IO_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::IO_ERR), &response->get()); } catch (const ErrorIllegalState& err) { - LoggerD("Library reported ErrorIllegalState!"); - ReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get()); } catch (const ErrorIllegalParameter& err) { - LoggerD("Library reported ErrorIllegalParameter!"); - ReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get()); } catch (const ErrorSecurity& err) { - LoggerD("Library reported ErrorSecurity!"); - ReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get()); } catch (const ExceptionBase& err) { - LoggerD("Library reported ExceptionBase!"); - ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get()); } }; @@ -256,20 +246,15 @@ void SecureElementInstance::OpenLogicalChannel( const picojson::value& args, pic picojson::value result = seSession.openLogicalChannel(v_aid); ReportSuccess(result, response->get()); } catch (const ErrorIO& err) { - LoggerD("Library reported ErrorIO!"); - ReportError(PlatformResult(ErrorCode::IO_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::IO_ERR), &response->get()); } catch (const ErrorIllegalState& err) { - LoggerD("Library reported ErrorIllegalState!"); - ReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get()); } catch (const ErrorIllegalParameter& err) { - LoggerD("Library reported ErrorIllegalParameter!"); - ReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get()); } catch (const ErrorSecurity& err) { - LoggerD("Library reported ErrorSecurity!"); - ReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get()); } catch (const ExceptionBase& err) { - LoggerD("Library reported ExceptionBase!"); - ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get()); } }; @@ -348,20 +333,15 @@ void SecureElementInstance::Transmit( const picojson::value& args, picojson::obj } ReportSuccess( result, response->get()); } catch (const ErrorIO& err) { - LoggerD("Library reported ErrorIO!"); - ReportError(PlatformResult(ErrorCode::IO_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::IO_ERR), &response->get()); } catch (const ErrorIllegalState& err) { - LoggerD("Library reported ErrorIllegalState!"); - ReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get()); } catch (const ErrorIllegalParameter& err) { - LoggerD("Library reported ErrorIllegalParameter!"); - ReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get()); } catch (const ErrorSecurity& err) { - LoggerD("Library reported ErrorSecurity!"); - ReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get()); } catch (const ExceptionBase& err) { - LoggerD("Library reported ExceptionBase!"); - ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get()); + LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get()); } }; diff --git a/src/secureelement/secureelement_seservice.cc b/src/secureelement/secureelement_seservice.cc index 27bf86ae..15fe4918 100644 --- a/src/secureelement/secureelement_seservice.cc +++ b/src/secureelement/secureelement_seservice.cc @@ -116,12 +116,12 @@ void SEService::GetReaders(double callback_id) { if (is_error_) { // there has been an error, report it asynchronously - LoggerE("Failed: is_error_"); std::shared_ptr response{new picojson::value{picojson::object{}}}; - ReportError( + LogAndReportError( PlatformResult(ErrorCode::SERVICE_NOT_AVAILABLE_ERR, "Unable to connect to service."), - &response->get()); + &response->get(), + ("Failed: is_error_")); TaskQueue::GetInstance().Async(get_readers_response, response); return; } -- 2.34.1