From: Pawel Andruszkiewicz
Date: Mon, 23 Feb 2015 11:12:33 +0000 (+0100)
Subject: [SecureElement] Updated try/catch code to match exceptions thrown from SE library.
X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~384
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=30c97f738848240ed771efdf52197bb13d97a4e5;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[SecureElement] Updated try/catch code to match exceptions thrown from SE library.
Try/catch cannot be removed, as exceptions are generated in library used
by this module.
Change-Id: I5a1ce4ce18d5422587a80ac6fa7f5835b306f4d1
---
diff --git a/src/secureelement/secureelement_instance.cc b/src/secureelement/secureelement_instance.cc
index 7dd9d46d..3c9456ae 100644
--- a/src/secureelement/secureelement_instance.cc
+++ b/src/secureelement/secureelement_instance.cc
@@ -8,7 +8,6 @@
#include
#include "common/picojson.h"
#include "common/logger.h"
-#include "common/platform_exception.h"
#include "common/task-queue.h"
#include "secureelement_reader.h"
@@ -142,9 +141,21 @@ void SecureElementInstance::OpenSession(
SEReader seReader(reader_ptr);
picojson::value result = seReader.openSession();
ReportSuccess(result, response->get());
- } catch (const PlatformException& err) {
- LoggerD("Error occurred while opening session!");
- ReportError(err, response->get());
+ } catch (const ErrorIO& err) {
+ LoggerD("Library reported ErrorIO!");
+ ReportError(PlatformResult(ErrorCode::IO_ERR), &response->get());
+ } catch (const ErrorIllegalState& err) {
+ LoggerD("Library reported ErrorIllegalState!");
+ ReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get());
+ } catch (const ErrorIllegalParameter& err) {
+ LoggerD("Library reported ErrorIllegalParameter!");
+ ReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get());
+ } catch (const ErrorSecurity& err) {
+ LoggerD("Library reported ErrorSecurity!");
+ ReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get());
+ } catch (const ExceptionBase& err) {
+ LoggerD("Library reported ExceptionBase!");
+ ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get());
}
};
@@ -176,8 +187,21 @@ void SecureElementInstance::OpenBasicChannel( const picojson::value& args, picoj
SESession seSession(session_ptr);
picojson::value result = seSession.openBasicChannel(v_aid);
ReportSuccess(result, response->get());
- } catch (const PlatformException& e) {
- ReportError(e, response->get());
+ } catch (const ErrorIO& err) {
+ LoggerD("Library reported ErrorIO!");
+ ReportError(PlatformResult(ErrorCode::IO_ERR), &response->get());
+ } catch (const ErrorIllegalState& err) {
+ LoggerD("Library reported ErrorIllegalState!");
+ ReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get());
+ } catch (const ErrorIllegalParameter& err) {
+ LoggerD("Library reported ErrorIllegalParameter!");
+ ReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get());
+ } catch (const ErrorSecurity& err) {
+ LoggerD("Library reported ErrorSecurity!");
+ ReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get());
+ } catch (const ExceptionBase& err) {
+ LoggerD("Library reported ExceptionBase!");
+ ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get());
}
};
@@ -203,10 +227,23 @@ void SecureElementInstance::OpenLogicalChannel( const picojson::value& args, pic
LoggerD("Opening basic channel");
try {
SESession seSession(session_ptr);
- picojson::value result = seSession.openBasicChannel(v_aid);
+ picojson::value result = seSession.openLogicalChannel(v_aid);
ReportSuccess(result, response->get());
- } catch (const PlatformException& e) {
- ReportError(e, response->get());
+ } catch (const ErrorIO& err) {
+ LoggerD("Library reported ErrorIO!");
+ ReportError(PlatformResult(ErrorCode::IO_ERR), &response->get());
+ } catch (const ErrorIllegalState& err) {
+ LoggerD("Library reported ErrorIllegalState!");
+ ReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get());
+ } catch (const ErrorIllegalParameter& err) {
+ LoggerD("Library reported ErrorIllegalParameter!");
+ ReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get());
+ } catch (const ErrorSecurity& err) {
+ LoggerD("Library reported ErrorSecurity!");
+ ReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get());
+ } catch (const ExceptionBase& err) {
+ LoggerD("Library reported ExceptionBase!");
+ ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get());
}
};
@@ -280,8 +317,21 @@ void SecureElementInstance::Transmit( const picojson::value& args, picojson::obj
arr.push_back(picojson::value(static_cast(transmit_response[i])));
}
ReportSuccess( result, response->get());
- } catch (const PlatformException& e) {
- ReportError( e, response->get());
+ } catch (const ErrorIO& err) {
+ LoggerD("Library reported ErrorIO!");
+ ReportError(PlatformResult(ErrorCode::IO_ERR), &response->get());
+ } catch (const ErrorIllegalState& err) {
+ LoggerD("Library reported ErrorIllegalState!");
+ ReportError(PlatformResult(ErrorCode::INVALID_STATE_ERR), &response->get());
+ } catch (const ErrorIllegalParameter& err) {
+ LoggerD("Library reported ErrorIllegalParameter!");
+ ReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR), &response->get());
+ } catch (const ErrorSecurity& err) {
+ LoggerD("Library reported ErrorSecurity!");
+ ReportError(PlatformResult(ErrorCode::SECURITY_ERR), &response->get());
+ } catch (const ExceptionBase& err) {
+ LoggerD("Library reported ExceptionBase!");
+ ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &response->get());
}
};
diff --git a/src/secureelement/secureelement_reader.cc b/src/secureelement/secureelement_reader.cc
index 92a49868..cbcf7457 100644
--- a/src/secureelement/secureelement_reader.cc
+++ b/src/secureelement/secureelement_reader.cc
@@ -8,10 +8,8 @@
#include
#include "common/picojson.h"
#include "common/logger.h"
-#include "common/platform_exception.h"
using namespace smartcard_service_api;
-using namespace common;
using namespace std;
namespace extension {