From 14c97f698dacf2692b0c3b659fcbdae7e8d5565f Mon Sep 17 00:00:00 2001 From: Andriy Gudz Date: Mon, 24 Jul 2017 19:51:41 +0300 Subject: [PATCH] Added global try-catch in utest --- device_core/utest/test_all.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/device_core/utest/test_all.cpp b/device_core/utest/test_all.cpp index ba68e09..add2662 100644 --- a/device_core/utest/test_all.cpp +++ b/device_core/utest/test_all.cpp @@ -6,10 +6,22 @@ std::string cloud_host{"coap+tcp://106.125.46.44:5683"}; int main(int argc, char** argv) { - if (argc > 1 && argv[1][0] != '-') + try { - cloud_host = std::string{"coap+tcp://"} + argv[1] + std::string{":5683"}; + if (argc > 1 && argv[1][0] != '-') + { + cloud_host = std::string{"coap+tcp://"} + argv[1] + std::string{":5683"}; + } + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + catch (std::exception& e) + { + std::cout << "Exception: " << e.what() << std::endl; + } + catch (...) + { + std::cout << "Unknown exception" << std::endl; + } + return -1; } -- 2.7.4