bin: factor exception-handling code
* bin/common_setup.cc, bin/common_setup.hh: Define a protected_main() function that deal with exceptions. * bin/autcross.cc, bin/autfilt.cc, bin/dstar2tgba.cc, bin/genaut.cc, bin/genltl.cc, bin/ltl2tgba.cc, bin/ltl2tgta.cc, bin/ltlcross.cc, bin/ltldo.cc, bin/ltlfilt.cc, bin/ltlgrind.cc, bin/ltlsynt.cc, bin/randaut.cc, bin/randltl.cc: Use it for all tools.
This commit is contained in:
parent
fc0ed01a45
commit
645bb55622
16 changed files with 328 additions and 386 deletions
|
|
@ -1496,13 +1496,10 @@ namespace
|
|||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
setup(argv);
|
||||
return protected_main(argv, [&] {
|
||||
const argp ap = { options, parse_opt, "[FILENAME[/COL]...]",
|
||||
argp_program_doc, children, nullptr, nullptr };
|
||||
|
||||
const argp ap = { options, parse_opt, "[FILENAME[/COL]...]",
|
||||
argp_program_doc, children, nullptr, nullptr };
|
||||
|
||||
try
|
||||
{
|
||||
// This will ensure that all objects stored in this struct are
|
||||
// destroyed before global variables.
|
||||
opt_t o;
|
||||
|
|
@ -1544,19 +1541,11 @@ main(int argc, char** argv)
|
|||
|
||||
// Diagnose unused -x options
|
||||
extra_options.report_unused_options();
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
error(2, 0, "%s", e.what());
|
||||
}
|
||||
catch (const std::invalid_argument& e)
|
||||
{
|
||||
error(2, 0, "%s", e.what());
|
||||
}
|
||||
|
||||
if (automaton_format == Count)
|
||||
std::cout << match_count << std::endl;
|
||||
if (automaton_format == Count)
|
||||
std::cout << match_count << std::endl;
|
||||
|
||||
check_cout();
|
||||
return !match_count;
|
||||
check_cout();
|
||||
return match_count ? 0 : 1;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue