Trick bugprone exception escape
Catching exceptions in main is annoying, because it prevents core dumps
from happening in systemd. We initially did this so we could enable
the bugprone-exception-escape check [1]. That documentation shows
that
"Functions declared explicitly with noexcept(false) or throw(exception)
will be excluded from the analysis,"
This seems like a better idea than catching all exceptions and printing.
Tested: bmcweb launches normally. clang-tidy passes.
[1] https://clang.llvm.org/extra/clang-tidy/checks/bugprone/exception-escape.html
Change-Id: I943b3b1c13bcbc21cd18f392cdc7574edf2f809e
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp
index c7c7fb4..99b7824 100644
--- a/src/webserver_main.cpp
+++ b/src/webserver_main.cpp
@@ -1,24 +1,6 @@
-
-
-#include "logging.hpp"
#include "webserver_run.hpp"
-#include <exception>
-
-int main(int /*argc*/, char** /*argv*/)
+int main(int /*argc*/, char** /*argv*/) noexcept(false)
{
- try
- {
- return run();
- }
- catch (const std::exception& e)
- {
- BMCWEB_LOG_CRITICAL("Threw exception to main: {}", e.what());
- return -1;
- }
- catch (...)
- {
- BMCWEB_LOG_CRITICAL("Threw exception to main");
- return -1;
- }
+ return run();
}