demo/arg_parser_demo.cc
changeset 842 c2ff0a365245
parent 440 88ed40ad0d4f
child 877 141f9c0db4a3
     1.1 --- a/demo/arg_parser_demo.cc	Fri Feb 12 22:24:26 2010 +0100
     1.2 +++ b/demo/arg_parser_demo.cc	Sun Feb 14 19:23:55 2010 +0100
     1.3 @@ -65,9 +65,18 @@
     1.4    ap.other("infile", "The input file.")
     1.5      .other("...");
     1.6  
     1.7 +  // Throw an exception when problems occurs. The default behavior is to
     1.8 +  // exit(1) on these cases, but this makes Valgrind falsely warn
     1.9 +  // about memory leaks.
    1.10 +  ap.throwOnProblems();
    1.11 +  
    1.12    // Perform the parsing process
    1.13    // (in case of any error it terminates the program)
    1.14 -  ap.parse();
    1.15 +  // The try {} construct is necessary only if the ap.trowOnProblems()
    1.16 +  // setting is in use.
    1.17 +  try {
    1.18 +    ap.parse();
    1.19 +  } catch (ArgParserException &) { return 1; }
    1.20  
    1.21    // Check each option if it has been given and print its value
    1.22    std::cout << "Parameters of '" << ap.commandName() << "':\n";