From: Piotr Czaja Date: Thu, 19 Feb 2015 14:09:00 +0000 (+0100) Subject: [TVDisplay] Remove try/catch to adjust to google coding style X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~385 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=529b188186d2a4501a652e869443789444087ec1;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [TVDisplay] Remove try/catch to adjust to google coding style [Verification] Code compiles without error. Change-Id: Iec3decae0eb683c556abafdc8803fd6859a0a65f Signed-off-by: Piotr Czaja --- diff --git a/src/tvdisplay/tvdisplay_instance.cc b/src/tvdisplay/tvdisplay_instance.cc index 7714e11c..e9cab15c 100644 --- a/src/tvdisplay/tvdisplay_instance.cc +++ b/src/tvdisplay/tvdisplay_instance.cc @@ -43,19 +43,23 @@ namespace { {SYSTEM_INFO_3D_MODE_2D_3D_CONVERSION, "FROM_2D_TO_3D"} }; - bool is_3D_enabled() { + common::PlatformResult is_3D_enabled(bool &is_3D_supported) { LOGD("Enter"); int is_supported = -1; int ret = system_info_get_value_int( SYSTEM_INFO_KEY_3D_SUPPORT, &is_supported); + if (SYSTEM_INFO_ERROR_NONE != ret) { std::string message = "'system_info' error while " "getting 3d mode details: " + std::to_string(ret); LOGE("%s", message.c_str()); - throw common::UnknownException(message); + return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, + "Unknown error. " + message); } - return is_supported == 1; + + is_3D_supported = (is_supported == 1); + return common::PlatformResult(common::ErrorCode::NO_ERROR); } } // namespace @@ -88,16 +92,19 @@ void TVDisplayInstance::Is3DModeEnabled( LOGD("Enter"); picojson::value::object o; std::string mode = "NOT_SUPPORTED"; - try { - if (is_3D_enabled()) { + bool is_3D_supported = false; + common::PlatformResult result = is_3D_enabled(is_3D_supported); + if (result.IsError()) { + LOGD("Error occured"); + ReportError(result, &out); + } else { + if (is_3D_supported) { mode = "READY"; } - } catch (const common::PlatformException & error) { - ReportError(error, out); - return; + LOGD("3D Mode is: %s", mode.c_str()); + picojson::value result(mode); + ReportSuccess(result, out); } - LOGD("3D Mode is: %s", mode.c_str()); - ReportSuccess(picojson::value(mode), out); } void TVDisplayInstance::Get3DEffectMode( @@ -152,47 +159,51 @@ void TVDisplayInstance::GetSupported3DEffectModeListTask( LOGD("Enter"); picojson::object & reply = (*data); - try { - std::vector modes; - if (!is_3D_enabled()) { - LOGD("3D is disabled"); - reply[kResult] = picojson::value(modes); - reply[kSuccess] = picojson::value(true); - return; - } - int flags = -1; - int result = system_info_get_value_int( - SYSTEM_INFO_KEY_3D_EFFECT_MODE, - &flags); - if (SYSTEM_INFO_ERROR_NONE != result) { - const char * kMessage = - "Fetching SYSTEM_INFO_KEY_3D_EFFECT_MODE failed"; - LOGE("%s: %d", kMessage, result); - throw common::UnknownException(kMessage); - } - - auto it = supported_3D_modes.begin(); - for (it; it != supported_3D_modes.end(); ++it) { - if (it->first & flags) { - modes.push_back(picojson::value(it->second)); - } - } + std::vector modes; + bool is_3D_supported = false; + common::PlatformResult res = is_3D_enabled(is_3D_supported); + if (res.IsError()) { + LOGD("Error occured"); + reply[kError] = res.ToJSON(); + return; + } + if (!is_3D_supported) { + LOGD("3D is disabled"); + reply[kResult] = picojson::value(modes); + reply[kSuccess] = picojson::value(true); + return; + } + int flags = -1; + int result = system_info_get_value_int( + SYSTEM_INFO_KEY_3D_EFFECT_MODE, + &flags); + if (SYSTEM_INFO_ERROR_NONE != result) { + const char * kMessage = + "Fetching SYSTEM_INFO_KEY_3D_EFFECT_MODE failed"; + LOGE("%s: %d", kMessage, result); + LOGD("Error occured"); + res = common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, + "Unknown error. " + std::string(kMessage)); + reply[kError] = res.ToJSON(); + return; + } - if (flags & SYSTEM_INFO_3D_MODE_FRAME_PACKING) { - LOGD("There is no FRAME_PACKING mode in TIZEN"); - } - if (flags & SYSTEM_INFO_3D_MODE_FRAME_DUAL) { - LOGD("There is no FRAME_DUAL mode in TIZEN"); + auto it = supported_3D_modes.begin(); + for (it; it != supported_3D_modes.end(); ++it) { + if (it->first & flags) { + modes.push_back(picojson::value(it->second)); } + } - reply[kResult] = picojson::value(modes); - reply[kSuccess] = picojson::value(true); - } catch (common::PlatformException const& error) { - reply[kError] = error.ToJSON(); - reply[kSuccess] = picojson::value(false); - } catch (...) { - LOGE("Unknown exception caught"); + if (flags & SYSTEM_INFO_3D_MODE_FRAME_PACKING) { + LOGD("There is no FRAME_PACKING mode in TIZEN"); } + if (flags & SYSTEM_INFO_3D_MODE_FRAME_DUAL) { + LOGD("There is no FRAME_DUAL mode in TIZEN"); + } + + reply[kResult] = picojson::value(modes); + reply[kSuccess] = picojson::value(true); } void TVDisplayInstance::GetSupported3DEffectModeListTaskAfter( diff --git a/src/tvdisplay/tvdisplay_instance.h b/src/tvdisplay/tvdisplay_instance.h index 3da6608d..e137bc18 100644 --- a/src/tvdisplay/tvdisplay_instance.h +++ b/src/tvdisplay/tvdisplay_instance.h @@ -11,6 +11,7 @@ #include "common/extension.h" #include "common/picojson.h" +#include "common/platform_result.h" namespace extension { namespace tvdisplay {