From: Hwankyu Jhun Date: Mon, 7 Apr 2025 23:46:20 +0000 (+0900) Subject: Use tizen_base::Exception class to throw exceptions X-Git-Tag: accepted/tizen/unified/20250516.055915~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32804390094f7f89726e2d1fc0fe44f44313a4d7;p=platform%2Fcore%2Fappfw%2Funited-service.git Use tizen_base::Exception class to throw exceptions Signed-off-by: Hwankyu Jhun --- diff --git a/src/service.cc b/src/service.cc index 975f766..217233a 100644 --- a/src/service.cc +++ b/src/service.cc @@ -18,9 +18,10 @@ #include -#include #include +#include +#include "exception.hh" #include "log_private.hh" #include "service_manager.hh" @@ -31,7 +32,7 @@ Service::Service(std::shared_ptr info, : info_(std::move(info)), listener_(std::move(listener)) { if (!Init()) { Shutdown(); - throw new std::runtime_error("Failed to initialize service"); + THROW(SERVICE_ERROR_INVALID_CONTEXT); } ServiceManager::GetInst().NotifyServiceStateChanged(this); @@ -127,7 +128,7 @@ void Service::Run() { int ret = tizen_core_task_run(task_); if (ret != TIZEN_CORE_ERROR_NONE) { _E("tizen_core_task_run() is failed"); - throw new std::runtime_error("Failed to run service"); + THROW(SERVICE_ERROR_INVALID_CONTEXT); } running_ = true; } @@ -165,7 +166,7 @@ void Service::SendMessage(const tizen_base::Bundle& envelope) { tizen_core_channel_object_destroy(object); if (ret != TIZEN_CORE_ERROR_NONE) { _E("tizen_core_channel_send() is failed. error=%d", ret); - throw new std::runtime_error("Failed to send message"); + THROW(SERVICE_ERROR_IO_ERROR); } } diff --git a/src/service_loader.cc b/src/service_loader.cc index 29e5c7e..18efc7e 100644 --- a/src/service_loader.cc +++ b/src/service_loader.cc @@ -41,7 +41,7 @@ ServiceLoader::ServiceLoader(int argc, char** argv, std::string name) : argc_(argc), argv_(argv), name_(std::move(name)) { if (!Init()) { Shutdown(); - throw new std::runtime_error("Failed to initializer service loader"); + THROW(SERVICE_ERROR_INVALID_CONTEXT); } }