Skip to content




JAR services

API Explorer

Handling undefined events and exceptions in Flux

If you try to give an event when there is no transition, Flux will throw an io.toro.fluxengine.exception.runtime.UndefinedEventException. If you'd like to respond to events that are not declared, you could create a transition with the $else event. This is useful when you have a dynamic value for $fluxEvent.

Flux also allows the catching of exceptions that may occur when a state's action is invoked. To do this, create a transition with $exception. Having this event provides the transition with an additional input called $fluxException, a GloopModel of reference io.toro.fluxengine.exception.runtime.FluxRuntimeException, that provides the details of the thrown exception. In particular, these are its properties:

  1. message - a String that contains the exception message
  2. type - a String that contains the simple class name of the exception
  3. className - a String that contains the class name of the exception
  4. realException - an Object that contains the actual exception
  5. fluxStackTrace - a GloopModel array of state and transition calls

fluxStackTrace contains an array of stacktrace elements that describes which states and transitions were invoked from the start of a Flux execution until the exception was thrown. A Flux stacktrace element consists of the following properties:

  1. fluxName - name of the Flux service
  2. stateName - name of the invoked state
  3. transition - event of the transition, null if the stacktrace element pertains to a state invocation
  4. stateIndex - index of the state on the Flux definition