From: Changgyu Choi Date: Tue, 4 Oct 2022 02:47:34 +0000 (+0900) Subject: Fix wrong exception handling X-Git-Tag: accepted/tizen/unified/20221104.082313~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F48%2F282448%2F4;p=platform%2Fcore%2Fappfw%2Frpc-port.git Fix wrong exception handling Change-Id: Ifd4f0104ad69dbcaddbdc31a75e84b676471716e Signed-off-by: Changgyu Choi --- diff --git a/benchmark/server/main.cc b/benchmark/server/main.cc index c4466cf..9be81a1 100644 --- a/benchmark/server/main.cc +++ b/benchmark/server/main.cc @@ -29,14 +29,14 @@ namespace bs = rpc_port::BenchmarkStub::stub; class TestService : public bs::Benchmark::ServiceBase { public: class Factory : public bs::Benchmark::ServiceBase::Factory { - public: - virtual ~Factory() = default; - - std::unique_ptr - CreateService(std::string sender, std::string instance) { - return std::unique_ptr( - new TestService(sender, instance)); - } + public: + virtual ~Factory() = default; + + std::unique_ptr + CreateService(std::string sender, std::string instance) { + return std::unique_ptr( + new TestService(sender, instance)); + } }; TestService(std::string sender, std::string instance) : @@ -75,9 +75,10 @@ class MainLoop { try { stub_.Listen(std::shared_ptr( new TestService::Factory())); - } catch (const std::exception& e) { - _E("stub listen is failed(%s)", e.what()); + } catch (const bs::Exception&) { + _E("stub listen is failed"); } + g_main_loop_run(loop_); } diff --git a/benchmark/tool/main.cc b/benchmark/tool/main.cc index 580eb69..8abe412 100644 --- a/benchmark/tool/main.cc +++ b/benchmark/tool/main.cc @@ -65,8 +65,8 @@ class Tester { void Run(int argc, char** argv) { options_ = rpc_port::benchmark::Options::Parse(argc, argv); if (!options_) { - _E("options is nullptr"); - exit(1); + std::cerr << "options is unllptr" << std::endl; + return; } ExecuteServer(); @@ -75,28 +75,36 @@ class Tester { try { proxy_->Connect(true); } catch (const bp::Exception& e) { - _E("Connect() failed"); - exit(1); + std::cerr << "Connect() failed" << std::endl; + return; + } catch (const std::exception& e) { + std::cerr << "Connect() failed. " << e.what() << std::endl; + return; } printf("%15s\t%15s\t%15s\t\t%15s\t\t%15s\n", "Iterations", "Data size", "Time", "Throughput", "Latency"); - if (options_->IsAll()) { - DoTest(4000, 10); - DoTest(4000, 20); - DoTest(4000, 100); - DoTest(4000, 200); - DoTest(2000, 1000); - DoTest(2000, 2000); - DoTest(1000, 10000); - DoTest(1000, 20000); - DoTest(1000, 30000); - DoTest(1000, 40000); - DoTest(1000, 50000); - DoTest(1000, 60000); - DoTest(500, 100000); - } else { - DoTest(options_->GetIters(), options_->GetSize()); + + try { + if (options_->IsAll()) { + DoTest(4000, 10); + DoTest(4000, 20); + DoTest(4000, 100); + DoTest(4000, 200); + DoTest(2000, 1000); + DoTest(2000, 2000); + DoTest(1000, 10000); + DoTest(1000, 20000); + DoTest(1000, 30000); + DoTest(1000, 40000); + DoTest(1000, 50000); + DoTest(1000, 60000); + DoTest(500, 100000); + } else { + DoTest(options_->GetIters(), options_->GetSize()); + } + } catch (const bp::Exception& e) { + std::cerr << "test failed" << std::endl; } } @@ -134,7 +142,8 @@ class Tester { } void EndTime(int iters, int size) { - std::chrono::duration sec = std::chrono::system_clock::now() - start_; + std::chrono::duration sec = + std::chrono::system_clock::now() - start_; double t = size * iters * 8 / sec.count() / 1024 / 1024; double l = sec.count() * 1000 / iters; @@ -175,11 +184,6 @@ class Tester { int main(int argc, char** argv) { Tester tester; - try { - tester.Run(argc, argv); - } catch (const std::exception& e) { - std::cerr << "Exception occurred!!!" << e.what() << std::endl; - } - + tester.Run(argc, argv); return 0; }