Exception handling

When a channel policy check rejects (PolicyResult.accept==false) a request, the WebSphere® Multichannel Bank Transformation Toolkit Channel driver will throw the com.ibm.btt.channel.ChannelPolicyException exception. By default, the WebSphere Multichannel Bank Transformation Toolkit presentation handler returns the exception to the client end. But a more user friendly error message to client end might be more appropriate. In this case, a technical developer must extend the channel presentation handler to handle the exception.

For example, in the HTML channel, the default presentation handler is
com.ibm.btt.cs.html.AjaxHtmlPresentationHandler 
or
com.ibm.btt.cs.html.HtmlPresentationHandler
To handle exceptions according to the requirements of specific applications, technical developers must extend either of the above presentation handlers and override the handleException method.
public void handleException(ChannelContext channelContext, Exception e)
In the method, the presentation handler handles any exception that is thrown while processing the request, and navigates a user to the proper error page with a proper message. Figure 1 is an example of the handleException method implementation to demonstrate how to handle ChannelPolicyException.
Figure 1. Example of the handleException method implementation

To apply the new presentation handler, technical developers must configure this presentation handler in the btt.xml file for the channel.