Closed domn1995 closed 4 years ago
I'm not a big fan of virtual properties. I think it's better to have it as an auto-property and set it through the base constructor (it can default to HResult in one of the overloads).
Regarding unit tests: we don't write any :)
As for functional tests, I'd say add a test to ErrorReportingSpecs
any of the simpler user-facing errors to make sure it also contains help text.
@Tyrrrz, ready for your input again. I've gone ahead and moved the exit code logic to BaseCliFxException
and added an FT for showing the help text on invalid user input.
That looks good. Now I'm wondering, should we just merge BaseCliFxException
and CliFxException
(and have CommandException
inherit from CliFxException
)? What do you think? I don't know if there's much benefit in keeping them separate.
Yeah, I think that's a good idea. Want me to update the PR?
Sure, go ahead.
@Tyrrrz, done and hopefully ready for a merge :)
Thanks!
Closes #16.
Notable Changes
showHelp: true
parameter to end-user-facingCliFxException
s.BaseCliFxException
to contain a virtualExitCode
property that returns its HResult by default.CommandException
's just override this property to set the exit code passed in its constructor or to the default exit code of-100
. This greatly simplified exception handling inCliApplication
and is a net reduction of 18 lines of code :)@Tyrrrz, can you double check that you're happy with these changes? If you like it, how would you prefer I implement unit tests? Should I augment the existing
ArgumentBindingSpecs
that throw the end-user-facing exceptions to also check that we're printing the help text or make brand new ones that assert we're throwing aCliFxException
AND displaying the help text?