Exceptions when in invalid state transition

97 views
Skip to first unread message

gandalf

unread,
Feb 16, 2012, 2:01:34 PM2/16/12
to Stateless .NET State Machine Framework
Hello,

Stateless throws InvlidOperationException when not permitted state
transfer is called. For example:

m_stateMachine.Configure(State.BuildingColumns)
.SubstateOf(State.Analyzing)
.Permit(Trigger.BuildRows, State.BuildingRows);

If called any trigger other than BuildRows, InvlidOperationException
will be thrown. Is it possible to configure stateless to transition to
an say error state if any or a particular exception is thrown in code?

Thanks

Grant BlahaErath

unread,
Feb 22, 2012, 7:35:17 PM2/22/12
to Stateless .NET State Machine Framework
Use the UnhandledTriggerMethod.

The goal, however, is to not have unhandled triggers in your state graph,
though that can be a tedious effort depending on the problem. I've used a
trick to partition my sub-states. Whenever the "CanFire" check fails, put
the trigger in a queue or stack. When when exiting the substate, pull a
trigger out of the queue. I've run into this condition a lot when
creating UX since fancy UI builds up a lot of states and triggers.

Good luck.

-g

Reply all
Reply to author
Forward
0 new messages