enable bugprone exception escape check
clang-13 includes new checks, and finds some issues. The first is that
the boost::vector constructor can possibly throw, so replace the
underlying flat_map container with std::vector instead.
The others are places where we could possibly throw in destructors,
which would be bad. Ideally we wouldn't use the destructor pattern, but
that would be non-trivial to clean up at this point, so just catch the
exception, and log it. At the same time, catch exceptions thrown to
main and log them.
Tested: Code compiles
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I77b86eaa2fc79e43d1ca044c78ca3b0ce0a7c38c
diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp
index bf98aae..b613008 100644
--- a/src/webserver_main.cpp
+++ b/src/webserver_main.cpp
@@ -61,7 +61,7 @@
}
}
-int main(int /*argc*/, char** /*argv*/)
+int run()
{
crow::Logger::setLogLevel(crow::LogLevel::Debug);
@@ -146,3 +146,16 @@
crow::connections::systemBus.reset();
return 0;
}
+
+int main(int /*argc*/, char** /*argv*/)
+{
+ try
+ {
+ return run();
+ }
+ catch (...)
+ {
+ return -1;
+ BMCWEB_LOG_CRITICAL << "Threw exception to main";
+ }
+}