[jira] [Commented] (VELOCITY-987) Directive to fail execution of the current template with an error message

"Claude Brisson (Jira)" <[email protected]>
Newsgroups gmane.comp.jakarta.velocity.devel
Message-ID <[email protected]>
    [ https://issues.apache.org/jira/browse/VELOCITY-987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18034766#comment-18034766 ] 

Claude Brisson commented on VELOCITY-987:
-----------------------------------------

The user did solve his problem. See:

* [the stackoverflow thread|https://stackoverflow.com/a/79333428/710286]
* [the corresponding Maven Doxia Sitetool issue|https://issues.apache.org/jira/browse/DOXIASITETOOLS-179]


> 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)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.