Subflow error management and return values.
Hi guys!
How should I handle errors in subflows? Let say I catch exception during executing the action in subflow. Should I explicitly define transition to the end-state on="error" in this action state or it is just enough to throw error event without showing transition?
Here are some snippets. In main flow:
Code:
<subflow-state flow="tools.DoSearch" id="tools.DoSearch">
<attribute-mapper bean="searchType.attributeMapper"/>
<transition to="selectSearch.view" on="finish"/>
<transition to="error" on="error"/>
</subflow-state>
and in subflow:
Code:
<action-state id="retrieveAction">
<action autowire="byType" method="retrieveStudiesFromArchive" class="StudyAction"/>
<transition to="overview" on="success"/>
<transition to="finish" on="error"/>
</action-state>
...
<end-state id="finish"/>
In code above I have transition to the end-state on error during action execution in subflow, and in definition of subflow I have transition to the error page if subflow execution finished with error. Is it right or I miss something?
Additionally, I read in docs that subflows can return values. Could you please give some more info about it and some examples?
Thanks a lot in advance.
Cheers,
Fuad
Webflow: Controlling flow with exceptions
Quote:
Originally Posted by kdonald
For recoverable errors, catch the exception in your action code and signal an appropriate error event so your flow can respond to it. By respond, I mean the flow will map the event to an appropriate state transition.
Hi,
I am suggesting another way of handling recoverable/checked exceptions:
http://sourceforge.net/mailarchive/m...sg_id=11479934
The solution lies in declaring checked exceptions in the flow configuration and declaring mapping that maps typed exceptions to appropriate events. All exception handling then would be only a way of flow configuration and it would take away the burden from developer to do the same exception handling in every action of the controller.
What do you think about this feature?
Thank you, Michal