-
Notifications
You must be signed in to change notification settings - Fork 51
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
print actual template errors on $stderr #125
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me - it is perfectly ok to use the parser inside the EvaluatingParser as it is considered API. You may want to also add output of any warnings or users may miss deprecations etc.
4bb029f
to
0c6ba2d
Compare
great point, added also parser exceptions are now properly rescued and added to the |
0c6ba2d
to
b401f48
Compare
b401f48
to
a3e52af
Compare
Previously the `EvaluatingParser` would implicitly call its own `#assert_and_report()` method, which in turn hands it over to the `IssueReporter#assert_and_report()` that tries to utilize puppet's internal logging but in our rake task this is not properly setup and thus the logged errors get lost. The result just leaves the validation summary output, e.g.: ``` Language validation logged 2 errors. Giving up (file: templates/configs/jenkins_casc.sh.epp) ``` Which obviously isn't very helpful to the user. This commit reworks the epp parsing and validation rake task, so that it instead prints out a nice summary on `$stderr` that contains all necessary information, e.g.: ``` ERRORS: templates/configs/jenkins_casc.sh.epp:1:17: Illegal parameter name. The given name 'CASC_JENKINS_CONFIG' does not conform to the naming rule /^[a-z_]\w*$/ templates/configs/jenkins_casc.sh.epp:4:33: Illegal variable name, The given name 'CASC_JENKINS_CONFIG' does not conform to the naming rule /^((::)?[a-z]\w*)*((::)?[a-z_]\w*)$/ ```
a3e52af
to
cd101f0
Compare
Good work on this! I think there is one more case to consider wrt. exceptions - I think there may be a LexError as well if the template does not even lex ok - for example a malformed number, string that isn't closed etc. I am not sure if this case is covered by the already rescued exceptions. |
There is a generic "catchall" rescue here: https://github.com/voxpupuli/puppet-syntax/pull/125/files#diff-a8986ba30354c68e43b0dc3441e884a2R61 which should take care of that. I was a bit torn between listing all of the possible expected Exceptions and just |
Previously the
EvaluatingParser
would implicitly call its own#assert_and_report()
method, which in turn hands it over to theIssueReporter#assert_and_report()
that tries to utilize puppet'sinternal logging but in our rake task this is not properly setup and
thus the logged errors get lost.
The result just leaves the validation summary output, e.g.:
Which obviously isn't very helpful to the user.
This commit reworks the epp parsing and validation rake task, so that it
instead prints out a nice summary on
$stderr
that contains allnecessary information, e.g.: