bmcweb: Show exception what() before exiting
Although exceptions should not happen in bmcweb, the underlying Crow
code sometimes throws, and so do bugs caused by accidental usage of
functions that throw.
Adding e.what() output when std::exception is thrown.
Tested: Accidentally tested more often than I would care to admit....
Signed-off-by: Josh Lehan <krellan@google.com>
Change-Id: Ifcd30dc53369708b21bf958c627755651422f18a
diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp
index b68e167..05c10cc 100644
--- a/src/webserver_main.cpp
+++ b/src/webserver_main.cpp
@@ -25,6 +25,7 @@
#include <vm_websocket.hpp>
#include <webassets.hpp>
+#include <exception>
#include <memory>
#include <string>
@@ -158,6 +159,11 @@
{
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";