chore(safe_main): work around Windows-specific issue in cpptrace

This commit is contained in:
Marcus Holland-Moritz 2025-05-08 20:36:25 +02:00
parent 2983764d40
commit 843c75ae69

View File

@ -52,6 +52,7 @@
namespace dwarfs::tool { namespace dwarfs::tool {
int safe_main(std::function<int(void)> const& fn) { int safe_main(std::function<int(void)> const& fn) {
int retval{1};
DWARFS_TRY { DWARFS_TRY {
install_signal_handlers(); install_signal_handlers();
setup_default_locale(); setup_default_locale();
@ -59,7 +60,7 @@ int safe_main(std::function<int(void)> const& fn) {
::_set_abort_behavior(0, _WRITE_ABORT_MSG); ::_set_abort_behavior(0, _WRITE_ABORT_MSG);
#endif #endif
return fn(); retval = fn();
} }
DWARFS_CATCH(...) { DWARFS_CATCH(...) {
std::cerr << "ERROR: " << exception_str(std::current_exception()) << "\n"; std::cerr << "ERROR: " << exception_str(std::current_exception()) << "\n";
@ -74,7 +75,7 @@ int safe_main(std::function<int(void)> const& fn) {
#endif #endif
#endif #endif
} }
return 1; return retval;
} }
} // namespace dwarfs::tool } // namespace dwarfs::tool