[
https://issues.apache.org/jira/browse/VELOCITY-987?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claude Brisson closed VELOCITY-987.
-----------------------------------
Resolution: Not A Bug
> Directive to fail execution of the current template with an error message
> -------------------------------------------------------------------------
>
> Key: VELOCITY-987
> URL: https://issues.apache.org/jira/browse/VELOCITY-987
> Project: Velocity
> Issue Type: New Feature
> Reporter: Arend von Reinersdorff
> Priority: Major
>
> My current use case is generating a Dockerfile and setting the base image
> according to a Java version parameter. Accepted values for Java versions are
> limited (17, 11, 8). Problem was when 21 was added as a new Java version, the
> if-block was not updated. Template generation succeeded using a fallback
> image and an error appeared later.
> If the fallback could have failed the template generation, the error would
> have been discovered sooner.
> *Requirements*
> * Directive to fail the template generation
> * Ability to add an error message
> * Error should lead to the place of failure (template file, line number)
> *Example usage*
> {code:java}
> #if (${javaVersion} == '21')
> FROM icr.io/appcafe/open-liberty:full-java21-openj9-ubi-minimal
> #elseif (${javaVersion} == '17')
> FROM icr.io/appcafe/open-liberty:full-java17-openj9-ubi
> #else
> #fail("Unsupported Java version: ${javaVersion}")
> #end{code}
> ErrorĀ message might loook like this:
> Template execution failed for example.vm line 6: Unsupported Java version: 11
> *Difference to stop*
> I am aware of the #stop directive. But as it doesn't fail the template
> generation. So it is not visible that an error occured.
> *See also*
> https://stackoverflow.com/questions/46587599/how-to-fail-velocity-template-processing-with-tracable-message
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]