You can use custom exception in HTML channels to make exception handling more customized.
About the task
After users define the HTML channel exception handler, and add the configuration in btt.xml, when this kind of exception is caught at an HTML channel layer, HTML custom exception handler executes it according to the predefined logic, such as turning to one specific error page.
Process
1 Create an error page, like helloWorldException.jsp and register this error page as errorPage for HTMLClient channel.
2 Defining custom exception handler by overriding preProcessException() to set the error page when an exception occurs:
public class CustomHtmlExceptionHandler extends HtmlExceptionHandler{ public void preProcessException(ChannelContext context, Throwable ex) { System.out.println("In CCL : The custom html exception handler is invoked!");
if (ex instanceof RuntimeException){ try { // set helloWorldException.jsp as error page super.setErrorPage("helloWorldException.jsp");