From 34915def57c1383cc0e85ee4b10cf314273f0d09 Mon Sep 17 00:00:00 2001 From: SuvarnaMeenakshi <50386592+SuvarnaMeenakshi@users.noreply.github.com> Date: Thu, 22 Aug 2019 14:59:15 -0700 Subject: [PATCH] [portsyncd]: Add default catch block in portsyncd (#1033) * Add default catch block in portsyncd * Updated error message with the right spelling * Update try block to throw exception of type runtime_error * Remove additional paranthesis in throw statement --- portsyncd/portsyncd.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/portsyncd/portsyncd.cpp b/portsyncd/portsyncd.cpp index b34a4a0b4204..2b72d29ac769 100644 --- a/portsyncd/portsyncd.cpp +++ b/portsyncd/portsyncd.cpp @@ -163,9 +163,15 @@ int main(int argc, char **argv) } catch (const std::exception& e) { - cerr << "Exception \"" << e.what() << "\" had been thrown in deamon" << endl; + cerr << "Exception \"" << e.what() << "\" was thrown in daemon" << endl; return EXIT_FAILURE; } + catch (...) + { + cerr << "Exception was thrown in daemon" << endl; + return EXIT_FAILURE; + } + return 1; } @@ -224,7 +230,7 @@ void handlePortConfigFile(ProducerStateTable &p, string file, bool warm) if (!infile.is_open()) { usage(); - throw "Port configuration file not found!"; + throw runtime_error("Port configuration file not found!"); } list header = {"name", "lanes", "alias", "speed", "autoneg", "fec"};