[jboss-jira] [JBoss JIRA] (WFLY-9621) Nonintuitive error message when for loop is used inside of if/try/batch constructs

Erich Duda (JIRA) issues at jboss.org
Tue Dec 19 10:11:01 EST 2017


     [ https://issues.jboss.org/browse/WFLY-9621?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Erich Duda reassigned WFLY-9621:
--------------------------------

    Assignee: Jean-Francois Denise  (was: Jason Greene)


> Nonintuitive error message when for loop is used inside of if/try/batch constructs
> ----------------------------------------------------------------------------------
>
>                 Key: WFLY-9621
>                 URL: https://issues.jboss.org/browse/WFLY-9621
>             Project: WildFly
>          Issue Type: Bug
>          Components: CLI
>    Affects Versions: 11.0.0.Final
>            Reporter: Erich Duda
>            Assignee: Jean-Francois Denise
>
> CLI enables to use for loop construct for looping over commands or operations. See WFCORE-3236 for details. Because of design limitations of CLI, using of for loop is not supported inside of if, try, for and batch constructs. However if you try to do that, error message is not intuitive in all cases and it is difficult to find out why the code does not work.
> Let's see on real examples.
> {code:title=Using for inside if}
> [standalone at embedded /] if (outcome != success) of /system-property=test:read-resource
> [standalone at embedded /] for propName in :read-children-names(child-type=system-property)
> [standalone at embedded /] echo $propName
> Unrecognized variable propName
> {code}
> As you can see in the example, when you write aforementioned commands into the CLI, no error is thrown until you use the variable declared in the for construct. Additionally the error message is not saying anything about that using of "for" is not allowed inside of "if".
> {code:title=Using for inside try}
> [standalone at embedded /] try
> [standalone at embedded /] for propName in :read-children-names(child-type=system-property)
> [standalone at embedded /] echo $propName
> Unrecognized variable propName
> {code}
> The same applies here as for "if" case.
> {code:title=Using for inside batch}
> [standalone at embedded /] batch
> [standalone at embedded / #] for propName in :read-children-names(child-type=system-property)
> The command is not available in the current context (e.g. required subsystems or connection to the controller might be unavailable).
> {code}
> In the batch case, the error message is better (it says that command is not available), but still it is not clear why the command is not available.
> {code:title=Using for inside for}
> [standalone at embedded /] for propName in :read-children-names(child-type=system-property)
> [standalone at embedded /] for propName in :read-children-names(child-type=system-property)
> for is not allowed while in for block
> {code}
> Using of nested for loops generates nice error message which clearly explains what is wrong. All other cases should throw similar error.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list