Closed dagwieers closed 3 years ago
The 'hints' should already be present in the msg
field, this is part of what we review for in modules.
Formalizing this as different field would make it 'required' ... which is a problem with existing code.
Why would formalizing hint
in a different field make it required ?
It would just be a recommendation to do it like this in the future.
I agree with @bcoca the actual error message should contain the hint of the error (or we add the error ourselves alongside the exception) about what we think it could be. Having another field to but this would just complicate something that I believe is quite simple to do.
@dagwieers i view it as 'requried' part of your msg
now, by making it an additional field it makes it seem optional, which I think leads to worse error messages, not better.
@bcoca Most of the error message do not include a hint today. So it is optional now anyway.
Proposal: Ability to set hints to fail_json and Fail-Json
Author: Dag Wieers <@dagwieers>
Date: 2017-07-06
Motivation
Very specific use-case. A common user error in Windows is the use of backslashes for paths and how Ansible handles these in YAML and as key=value syntax.
So we added a test to check if the provided path is a valid path or not (it doesn't include any escape sequences by accident, like \t or \v). So that the output to the user goes from:
to:
We want to be able to extend this output to something more helpful to users:
The ability to add a hint to error messages is something that everybody should be using more often, and by splitting the message (fact) from the hint (possible resolutions) we make it much more convenient for the user than the common practice today of adding some hints to the error message.
If developers start using this more often in their code, they will also start to think about the possible failure cases and potential hints they have to provide. So we are less likely to get catchall exception-handling as a result and happier users !
Problems
What problems exist that this proposal will solve?
Solution proposal
hint:
to the fail moduledisplay_hints
so users can disable it