/** * \brief Main entry point for skeleton. * * Override this if you want to catch exceptions other than std:::exception or you * want to supply custom exception handling code. Make sure you don't change the * try { } block in your implementation and only call safe_main(). */ virtual int main(int argc, char **argv, bool noargs) { try { return safe_main(argc, argv, noargs); } catch (const std::exception& e) { if (logging_enabled()) { MLOG_DEFAULT_FATAL(e.what()); } throw; // will be caught by main template below } catch (...) { if (logging_enabled()) { MLOG_DEFAULT_FATAL("unknown exception caught"); } throw; // will be caught by main template below } return 1; }
int main(int argc, char const* argv[]) { try { safe_main(argc, argv); return EXIT_SUCCESS; } catch(std::runtime_error const& e) { std::cerr << "Fatal: " << e.what() << std::endl; return EXIT_FAILURE; } }
int main(int argc, char* argv[]) { try { safe_main(argc, argv); return 0; } catch(std::exception& e) { std::cout << "Exception: " << e.what() << std::endl; return 1; } }