@Override
public WOResponse handleException(Exception exception, WOContext context) {
WOResponse response;
if (context != null && AjaxUtils.isAjaxRequest(context.request())) {
ERXRedirect redirect = pageWithName(ERXRedirect.class, context);
redirect.setDirectActionName("error");
response = redirect.generateResponse();
} else {
SPErrorPage errorPage = pageWithName(SPErrorPage.class, context);
errorPage.setException(exception);
response = errorPage.generateResponse();
}