Overview
Features
Download
Documentation
Community
Add-Ons & Services

Invalid Option handling

Please post support and help requests here.

Invalid Option handling

Postby gandriotakis » 26 Sep 2012, 18:06

Is it possible to handle or ignore an invalid option in a ServerApplication? It appears that when one is encountered the application just exits.
gandriotakis
 
Posts: 29
Joined: 02 Dec 2011, 20:45

Re: Invalid Option handling

Postby gandriotakis » 04 Oct 2012, 15:03

I really need some help here. I am going to need to bypass the framework option handling and build my own unless there is a better option. It seems very unfriendly to just exit if the user enters a typo. I would expect at least an exception that could be caught and handled.
gandriotakis
 
Posts: 29
Joined: 02 Dec 2011, 20:45

Re: Invalid Option handling

Postby fbraem » 04 Oct 2012, 15:20

You can catch UnknownOptionException
Zumuta!, that's the way to do IT!
fbraem
 
Posts: 104
Joined: 11 Aug 2008, 22:47
Location: Belgium

Re: Invalid Option handling

Postby gandriotakis » 04 Oct 2012, 22:26

The exception is thrown from OptionSet::getOption method. The application level method that can catch it is the application run method which is hidden in the startup macro where it is too late to recover

I guess I will have to use my own startup. Even at that the only way to recover is to modifiy the arguments and try again. I would prefer to be able to just skip over invalid arguments (and possible log an error).
gandriotakis
 
Posts: 29
Joined: 02 Dec 2011, 20:45

Re: Invalid Option handling

Postby mv2020 » 21 Mar 2013, 22:23

I'm also having problems with this. The options processing throws exceptions way too generously and early, resulting in "Unknown option specified: X" for any undefined options. I think it should process what it can and pass any unhandled options directly to the overridden main(ArgVec const&) method. The library shouldn't swallow up the unhandled options and die. What if you want to pass options through to some subprocess (like I currently want to)? I tested this with both the Application and ServerApplication classes, and the behavior is the same in both in the 1.5-dev code.
mv2020
 
Posts: 1
Joined: 21 Mar 2013, 22:18


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron