exception logger

This commit is contained in:
shweet committed 2026-05-11 17:55:00 -04:00
1 parent b345c27a87
commit e6a4065777
3 files changed
+32 -6

No files matched your search

+19
View File
@@ -1,6 +1,7 @@
#include "log.hpp"
#include <array>
#include <exception>
#include <format>
#include <print>
@@ -151,6 +152,24 @@ namespace anm2ed
info("Exiting Anm2Ed");
stderr_redirect_stop();
}
int log_exceptions(const std::function<int()>& callback)
{
try
{
return callback();
}
catch (const std::exception& e)
{
logger.fatal(std::format("Unhandled exception: {}", e.what()));
}
catch (...)
{
logger.fatal("Unhandled non-standard exception");
}
return EXIT_FAILURE;
}
}
anm2ed::Logger logger;