commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rahul Akolkar" <rahul.akol...@gmail.com>
Subject Re: [scxml] Handling exceptions thrown by custom actions
Date Tue, 16 May 2006 18:44:42 GMT
On 5/15/06, Nestor Urquiza <nestoru@yahoo.com> wrote:
> Hello guys,
> Could you point me to what you think might be the best
> approach here?
>
> I receive a request and pass that request to the scxml
> engine by means of triggering the proper event. The
> event then put the FSM in an action state where some
> internal methods (custom actions) are called.
>
> How could I just suspend the whole execution of the
> trigger and go back to the state the application was
> before receiving the external event? Right now if an
> exception is thrown from a custom action then a  new
> SCXMLExpressionException(e) is thrown as well so the
> FSM stops and therefore the FSM stops at the action
> state while of course I want it to go back to the
> original state.
>
<snip/>

This has been asked before, so please allow me to paste just the
relevant bit from an earlier post [1]:

<PASTE>

A more useful mechanism than throwing a Java exception is to catch the
error condition / checked exception and fire a derived error event on
the state machine.

In the <my:action>'s execute() method:

// on error condition or checked exception
derivedEvents.add(new TriggerEvent("err.foo",
  TriggerEvent.ERROR_EVENT));

And the SCXML snippet:

<state id="foo">
  <onentry>
    <my:action ... />
  </onentry>
  <transition event="err.foo" target="errorstate" />
  <!-- other transitions etc. -->
</state>

</PASTE>

This, along with the SCXML <history> element, will get you what you need here.

-Rahul

[1] http://marc.theaimsgroup.com/?l=jakarta-commons-user&m=114344354313954&w=2


> Thanks a lot,
> Nestor Urquiza
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message