From 12cae1e6348f4f66d167ce643ccecf2793927ef7 Mon Sep 17 00:00:00 2001 From: redPanther Date: Sun, 10 Jul 2016 12:18:40 +0200 Subject: [PATCH] catch exceptions in hyperiond (#92) --- src/hyperiond/main.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/hyperiond/main.cpp b/src/hyperiond/main.cpp index 7177d2ea..038e135b 100644 --- a/src/hyperiond/main.cpp +++ b/src/hyperiond/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -144,16 +145,24 @@ int main(int argc, char** argv) hyperiond = new HyperionDaemon(configFiles[argvId], &app); hyperiond->run(); } - catch (...) + catch (std::exception& e) { - Error(log, "Hyperion Daemon aborted"); + Error(log, "Hyperion Daemon aborted:\n %s", e.what()); } - WebConfig* webConfig = new WebConfig(&app); - - // run the application - int rc = app.exec(); - Info(log, "INFO: Application closed with code %d", rc); + int rc = 1; + WebConfig* webConfig = nullptr; + try + { + webConfig = new WebConfig(&app); + // run the application + rc = app.exec(); + Info(log, "INFO: Application closed with code %d", rc); + } + catch (std::exception& e) + { + Error(log, "Hyperion aborted:\n %s", e.what()); + } // delete components delete webConfig;