0

I am using Scriptrunner and I would like to throw an exception because the issue has no components as shown below:  enter image description here

How can I do that? 

I am using the following code and I am checking if the components are empty but the error is not thrown. How can I fix this?

package SuperFeature

import com.opensymphony.workflow.WorkflowException

def components = issue.components

log.warn("MOUNA COMPONENTS "+components)

if(components.empty) {

         log.warn("MOUNA EMPTY")

          throw new WorkflowException("Issue does not have components")

}
  • There are some information missing to help you. Where did you put that script in? As an inline script? Or file somewhere? Did you created it with a Validator script? Or Condition script? Or as something else? And what exactly do you want to achieve? When do you want that exception / error message to be shown? – TheFRedFox Aug 27 '23 at 13:14

1 Answers1

1

When you use ScriptEunner WEB Console, you should return some value, throwing the Exception will not work in most cases. You can structure the code of the script in such a way that you break/stop operation or return false/null/etc. depending on who is the consumer of the Error/Exception.

Andrii Maliuta
  • 331
  • 2
  • 7