
On Tue, Jun 19, 2012 at 6:12 AM, Roger Martin <roger@quantumbioinc.com>wrote:
Hi boost,
At version 1.49.0
In testing command line with known unknowns such as -V a location unknown exception is thrown from inside program_options recommending to use BOOST_THROW_EXCEPTION. I've been trying to find this and apply BOOST_THROW_EXCEPTION to eliminate the verbosity for users: ---- Command line incorrect: Throw location unknown (consider using BOOST_THROW_EXCEPTION) Dynamic exception type: boost::exception_detail::** clone_impl<boost::exception_**detail::error_info_injector<** boost::program_options::**unknown_option> > std::exception::what: unknown option -V
The output you're seeing is generated by boost::diagnostic_information, and that's not a user-friendly but rather a diagnostic message. The suggestion to use BOOST_THROW_EXCEPTION refers to the "Throw location unknown". If BOOST_THROW_EXCEPTION was used by the library, the diagnostic message would have been more complete and include the file/line of the throw. Just catch boost::program_options::unknown_option and display a user-friendly message: catch( boost::program_options::unknown_option & e ) { std::cerr << "Unknown option!"; } catch( ... ) { std::cerr << "Unrecognized exception, diagnostic information follows\n" << boost::current_exception_diagnostic_information(); } Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode