adrianaisemberg/CLAP

Create base exception class for all CLAP exceptions

AGlezB opened this issue · 2 comments

Currently the only way to distinguish CLAP exceptions from the exceptions thrown by user code in the [Error] handling method is to test for every type like:

if(context.Exception is CommandLineParserException){ /* ... */ }
else if (context.Exception is VerbNotFoundException){ /* ... */ }
/* ... test every CLAP.*Exception ... */
else { /* Handle user code exception */}

It would be a lot easier to just check the base class:

if(context.Exception is CLAPBaseExeption){ /* Handle CLAP exceptions */ }
else { /* Handle user exception */}

Yes you can wrap every verb method code inside a try-catch instead but that is not nearly as convenient.

Neat idea. I love it.
Do you want to send a PR?

Do you want to send a PR?

I wish but don't have the time. Sorry. 😢
This things tend to come out just when you have a client breathing on your neck. 😄