Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Question

Just throw a new Exception("Xxx")? That gives me Unexpected type: java.lang.Exception. Is there some exception class I can use for this?

...

hiddentrue

...

Answer

Use throwException(String errorMessage)

For details see: https://qa.pricefx.eu/pricefx-api/groovy/develop/net/pricefx/formulaengine/scripting/PublicGroovyAPI.html#throwException-java.lang.String-

A calculation logic can stop its execution and fail by throwing an exception, for example:

Code Block
if (api.userEntry("margin") <0)
then api.throwException("I won't let you go bankrupt") 
else price=cost+margin
Info

See also How to Save Logic that Is Evaluated as Erroneous by Syntax Checker.