-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusing error message when missing "required" options #16
Comments
At the very least, I would like a PR that gets rid of the "in call to eval" and says something like "--foo is required but was not given" yes. :) |
@rjbs I can't figure out how to do it in a non-brittle fashion -- if the error messages from PV change, any munging is going to break. I'll try to make it so it just passes through the PV error if it is not recognizable. I can see another weird error message, in the case of
Should I include a fix for this, too? |
@fgabolde Did you ever start in on a patch for this? I'd love to see a better error message. |
If you haven't started, I might! |
@tsibley I think I have the start of a patch on my work machine yes, but nothing very finished. I don't have access to it right now but I don't remember having gone far with it -- if you're still interested in this patch you're probably better off not waiting for me to finish :/ although I can send you what I've done if I can find it on Monday. |
Params::Validate allows for changing the calculated The best option would be if Params::Validate had exception objects that Getopt::Long::Descriptive could catch and use to build its own error messages. That sounds like a lot of work though and involves patches to other modules. Another option then is parsing the messages to figure out what went wrong and trying to reassemble better ones. Obviously we can't parse everything perfectly (and it will be somewhat brittle if Params::Validate changes), but we can try to parse common errors that might happen. Two that come to mind from my experience are:
Scrolling through Params::Validate::PP looking at calls to ¹ Example:
|
@fgabolde Ok, thanks! I'd be curious to see what headway you made, but if you can't dig it up no worries. |
@tsibley Sorry, it disappeared along with my old hard drive, I think. |
Hi, Is there any progress on that? Ugly |
Not that I'm aware of. |
When a script specifies "required" options:
and the user forgets to include them, we get a confusing error message:
Now I know what's meant because I'm used to GLD's idiosyncrasies but it's not very user-friendly...
Looking at the source, I can see it's because Params::Validate is assuming it's being called as
validate()
within a function, so it can include its name in the error message (and GLD is in fact callingvalidate_with()
in an eval). I checked, and there seems to be no way to tell Params::Validate not to include the caller name (although there is a way to tell it to skip some frames from the stack... but of course the "correct" caller would just be "(unknown)" in that case, so that's not much better). There remains the possibility to munge the error message within the customon_fail
handler in GLD.Does that sound like a PR you'd want?
The text was updated successfully, but these errors were encountered: