Boost logo

Boost :

Subject: Re: [boost] program options (consider using BOOST_THROW_EXCEPTION)
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2012-06-27 16:51:53


On Wed, Jun 27, 2012 at 4:46 AM, Leo Goodstadt <leo.goodstadt_at_[hidden]>wrote:

> However, the majority of exceptions in program_options are there to
> indicate a problem in the construction of the command line by the
> *end-user* (not the programmer).
> In other words, the program *is* working exactly as designed.

Unless it's buggy.

The
> programmer has no interest in the provenance of these exceptions
> *except* that they can be used to inform the end-user how they should
> retype the command line and try again.
>

The use case is this:

int main( int argc, char const * argv[] )
{
  try
  {
    do_work(parse_command_line(argc,argv));
  }
  catch( X & )
  {
  }
  catch( Y & )
  {
  }
  catch(...)
  {
    std::cerr << boost::current_exception_diagnostic_information();
    abort();
  }
}

The catch(...) shouldn't be reached. The BOOST_THROW_EXCEPTION information
could help if it is (of course the message is intended for the programmer,
not the end user.)

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk