From: Matt W. <st...@gm...> - 2011-01-07 07:19:47
|
I've just released the first publicly available version - 0.1.1 (alpha 1) - of Pantheios::Extras::Main; details here. It allows a user to replace code such as: char const PROGRAM_NAME[] = "myprogram"; int main(int argc, char** argv) { try { . . . // program logic return EXIT_SUCCESS; } catch(std::bad_alloc&) { pantheios::logputs(pantheios::alert, "out of memory"); fprintf(stderr, "%s: out of memory\n", PROGRAM_NAME); } catch(std::exception& x) { pantheios::log_CRITICAL(x); fprintf(stderr, "%s: %s\n", PROGRAM_NAME, x.what()); } catch(...) { pantheios::logputs(pantheios::emergency, "unexpected unknown failure"); fprintf(stderr, "%s: unexpected unknown failure\n", PROGRAM_NAME); } return EXIT_FAILURE; } with: char const PROGRAM_NAME[] = "myprogram"; int program(int argc, char** argv) { . . . // program logic return EXIT_SUCCESS; } int main(int argc, char** argv) { return pantheios::extras::main::invoke(argc, argv, program, PROGRAM_NAME); } As discussed in the sixth instalment of Quality Matters, Exceptions for Practically-Unrecoverable Conditions, without an exhaustive top-level try-catch statement, program robustness cannot be averred. Pantheios::Extras::Main let's you achieve that in a single statement. -- Posted By Matt Wilson to Pantheios Tips 'n' Tricks at 1/06/2011 11:16:00 PM |