You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if an exception is thrown as a result of invoking a bean invoking action, the exception propagates back to the flow and the flow is expected to respond to the exception using either an exception handler typically or by declaring an on exception transition. This works fine but generally requires transition to a intermediate state to map the exception onto a set of error validation methods. Either that or the view must translate the exception to error messages. It would be nice if the bean invoking action itself could handle the exception, record suitable validation error messages and return a result that could be handled by the flow. This would make exception handling simpler from the flow definition point of view and build in alert creation.
Using transition on-exception is no doubt elegant and powerful. However, it's arguably redundant when all you want to do is map the exception to an error message and logical error outcome, then redisplay a view. Having to implement this same control flow logic over and over again for every call into the service-layer that throws a checked exception results in duplication. It seems we have a natural opportunity to encapsulate some of this inside the bean invoking action itself to simplify exception handling for users (via convention over repetitive configuration).
nebhale opened SWF-321 and commented
Currently, if an exception is thrown as a result of invoking a bean invoking action, the exception propagates back to the flow and the flow is expected to respond to the exception using either an exception handler typically or by declaring an on exception transition. This works fine but generally requires transition to a intermediate state to map the exception onto a set of error validation methods. Either that or the view must translate the exception to error messages. It would be nice if the bean invoking action itself could handle the exception, record suitable validation error messages and return a result that could be handled by the flow. This would make exception handling simpler from the flow definition point of view and build in alert creation.
For example before this feature you'd do this:
<action-state id="changeBeneficiaryAllocations">
<bean-action bean="accountManager" method="updateBeneficiaryAllocationPercentages">
<method-arguments>
<argument expression="flowScope.accountId" />
<argument expression="requestScope.allocationPercentages" />
</method-arguments>
</bean-action>
<transition on="success" to="editBeneficiaries" />
<transition on-exception="accounts.InvalidAllocationException" to="generateErrorMessages"/>
</action-state>
after you'd do this:
<action-state id="changeBeneficiaryAllocations">
<bean-action bean="accountManager" method="updateBeneficiaryAllocationPercentages">
<method-arguments>
<argument expression="flowScope.accountId" />
<argument expression="requestScope.allocationPercentages" />
</method-arguments>
</bean-action>
<transition on="success" to="editBeneficiaries" />
<!-- Error message generated automatically -->
<transition on="invalidAllocation" to="enterNewBeneficiaryAllocations"/>
</action-state>
Affects: 1.0.3
Issue Links:
("depends on")
1 votes, 2 watchers
The text was updated successfully, but these errors were encountered: