From df38ef1ec9af4f3f893323ed5c10e25fa481b1c6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 19 Sep 2025 20:28:04 +0100 Subject: Gracefully handle fatal exceptions and display message --- src/webstat_logger_main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/webstat_logger_main.cpp b/src/webstat_logger_main.cpp index 7817dc0..d30da80 100644 --- a/src/webstat_logger_main.cpp +++ b/src/webstat_logger_main.cpp @@ -57,6 +57,12 @@ main(int argc, char ** argv) po::notify(optVars); auto pool = std::make_shared(dbMax, dbKeep, std::move(dbType), std::move(dbConnStr)); - WebStat::Ingestor {getHostDetail(), pool}.ingestLog(stdin); - return EXIT_SUCCESS; + try { + WebStat::Ingestor {getHostDetail(), pool}.ingestLog(stdin); + return EXIT_SUCCESS; + } + catch (const std::exception & excp) { + std::println(std::cerr, "Unhandled error: {}", excp.what()); + return EXIT_FAILURE; + } } -- cgit v1.2.3