Editing Unified Exception Class - Program Options Suggestion
BOOST WIKI
|
RecentChanges
|
Preferences
|
Page List
|
Links List
== Unified exception class == Back to [[Suggestions - program_options library]] ---- program_option's exceptions should be grouped under one struct. Currently, we have, e.g.: <pre> class validation_error : public error { ... }; </pre> Instead, it should be <pre> class program_options_exception : public error { ... }; class validation_error : public program_options_exception { ... }; </pre> Then, for example, you could have: <pre> try { ... } catch (exception& e) { if (dynamic_cast<program_options_exception*>(&e)) cout << "Usage: " << ...; } </pre> to print a usage message only in the case of a program_options-generated exception. - [[People/Chuck Messenger]] ---- Actually, "error" is "boost::progam_options::error" --- i.e. it's the class from which all program options exceptions are derived. Is that already what you propose? - [[People/Vladimir Prus]] ---- Oh -- so you've got your own "error"? Yes, that satisfies what I wanted. But, the symbol "error" doesn't seem wise. I had assumed (probably wrongly) that "error" was in the std namespace. (Maybe I was thinking of "exception"). Even so, the word "error" is much too common to be used in program_option's top level. What happens when a user does "using namespace program_options;" (which is my typical way of using boost libs)? You might counter that you can always specify program_options::error. But I feel the genericness of the name is problematical. What if a user doesn't qualify "error"? Symbols in a library's toplevel namespace should, I feel, be reasonably specific to the library's domain. I suggest changing "error" to "program_options_error". - [[People/Chuck Messenger]] ---- I somehow don't like boost::program_options::program_options_error. I'm -0 on this proposal -- whatever reviewers in general will decide, will do. - [[People/Vladimir Prus]] ----
Summary:
This change is a minor edit.
(Visit
Preferences
to set your user name.)
View other revisions
BOOST WIKI
|
RecentChanges
|
Preferences
|
Page List
|
Links List
Disclaimer: This site not officially maintained by Boost Developers