[ 
https://issues.apache.org/jira/browse/TEXT-127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16562042#comment-16562042
 ] 

Sebb commented on TEXT-127:
---------------------------

I think what you are asking for is:

{code:java}"${unknown:-default}" // => default (i.e. as a present}{code}
{code:java}"${unknown}" // => exception (this is new behaviour){code}

Since this is new behaviour, it has to be optional, e.g. have a method 
setFailOnUndefinedVariable(boolean) which changes the behaviour where there is 
no default.

> Detect when a variable is unknown in StringSubstitutor
> ------------------------------------------------------
>
>                 Key: TEXT-127
>                 URL: https://issues.apache.org/jira/browse/TEXT-127
>             Project: Commons Text
>          Issue Type: Improvement
>            Reporter: Jean-Baptiste REICH
>            Priority: Minor
>
> Currently, StringSubstitutor is not replacing a variable that is unknown. It 
> would be nice to define the behavior in this case and to allow raising an 
> exception.
> A workaround is to define a custom StringLookup that raises an exception when 
> the variable is unknown but this prevent from using the default value feature 
> from StringSubstitutor



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to