By animesh.prasad on Jun 27, 2012
Exception thrown in a task flow gets wrapped in an exception that gives an unintelligible error message to the user.
Solution 1. Over-writing the error message with a user-friendly error message.
Steps to code
1. Generating an exception: Write a method that throws an exception and drop it in the task flow.
2. Adding an Exception Handler: Write a method (example below) to overwrite the Error in the bean or data control and drop the method in the task flow.
This method is marked as the Exception Handler by Right-Click on method > Mark Activity> Exception Handler or by the button that is displayed in this screenshot
The Final task flow should look like this. This will overwrite the exception with the error message in figure 2.
Note: There is no need for a control flow between the two method calls (as shown below).
Solution 2: Re-Routing the task flow to display an error page
Steps to code
1. This is the same as step 1 of solution 1.
2. Adding an Exception Handler: The Exception handler is not always a method; in this case it is implemented on a task flow return. The task flow looks like this.
In the figure below you will notice that the task flow return points to a control flow ‘error’ in the calling task flow.
This control flow in turn goes to a view ‘error.jsff’ which contains the error message that one wishes to display. This can be seen in the figure below. (‘withErrorHandling’ is a call to the task flow in figure 7)