use boost to catch all exceptions

This commit is contained in:
陈浩南 2024-05-05 10:14:24 +08:00
parent 3a4ba7a94f
commit 1afa693fd8

View File

@ -7,6 +7,7 @@
# include <hpcstat/lfs.hpp> # include <hpcstat/lfs.hpp>
# include <fmt/format.h> # include <fmt/format.h>
# include <range/v3/view.hpp> # include <range/v3/view.hpp>
# include <boost/exception/diagnostic_information.hpp>
int main(int argc, const char** argv) int main(int argc, const char** argv)
{ {
@ -123,7 +124,6 @@ int main(int argc, const char** argv)
} }
else { std::cerr << "Unknown command.\n"; return 1; } else { std::cerr << "Unknown command.\n"; return 1; }
} }
catch (const std::exception& e) { std::cerr << fmt::format("Exception: {}\n", e.what()); return 1; } catch (...) { std::cerr << boost::current_exception_diagnostic_information() << std::endl; return 1; }
catch (...) { std::cerr << "Unknown exception.\n"; return 1; }
return 0; return 0;
} }