Improve reporting of deserializer validation errors #550
+14
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I was looking for a "dead simple" problem just to get my feet damp. Issue #205 stood out. (A comment on that issue includes some detailed analysis.)
Deserialization of some parameters like
--datatakes place duringrunrather than during Click option processing. Errors raise a validation exception, but to the Click CLI infrastructure this is an unexpected exception and causes a full traceback which is not generally useful to the user.This change intercepts internal validation error exceptions and raises a Click
BadParameterexception encapsulating the validation error text. This will be reported without traceback.Details
This simply wraps the
asyncio.runwhich starts benchmarking (and runs the deserializers) with a try block to convert the deserializer'sValueErrorintoclick.BadParameterso that Click can generate a better usage message and will suppress the traceback which can obscure the message.Test Plan
This only affects the output of a validation error in benchmark run startup, removing the traceback. While it's not impossible to imagine a
CliRunnertest for this case, the output analysis would be a bit tedious and it didn't seem worthwhile. (Feel free to tell me otherwise! Currently,test_main.pyis rather light on content.)Related Issues
This is "inspired by" #205 but possibly doesn't actually resolve it.
Use of AI
## WRITTEN BY AI ##)