Source:
public void handle() { final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); while (i.hasNext()) { ExceptionQueuedEvent event = i.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.error("An exception occurred while performing user request", t); final FacesContext fc = FacesContext.getCurrentInstance(); final Map<String, Object> requestMap = fc.getExternalContext().getRequestMap(); final NavigationHandler nav = fc.getApplication().getNavigationHandler(); HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest(); Object servletEx = request.getAttribute("javax.servlet.error.exception"); try { if (servletEx instanceof SanitizationException) { fc.addMessage("errorMessage", new FacesMessage(FacesMessage.SEVERITY_ERROR, "An Exception occurred while performing the requested function.", "")); requestMap.put("exceptionMessage", ((SanitizationException) servletEx).getMessage()); nav.handleNavigation(fc, null, NavigationConstant.CUSTOM_ERROR_XHTML); } else if (t instanceof ViewExpiredException) { fc.addMessage("loginErrors", new FacesMessage(FacesMessage.SEVERITY_ERROR, "Your session has expired, please login!", "")); nav.handleNavigation(fc, null, NavigationConstant.LOGIN_XHTML); } else { fc.addMessage("errorMessage", new FacesMessage(FacesMessage.SEVERITY_ERROR, "An Exception occurred while performing the requested function.", "")); requestMap.put("exceptionMessage", t.getMessage()); fc.getExternalContext().invalidateSession(); nav.handleNavigation(fc, null, NavigationConstant.CUSTOM_ERROR_XHTML); } fc.renderResponse(); } finally { i.remove(); } } getWrapped().handle(); }

Target:
public void handle() { final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); while (i.hasNext()) { ExceptionQueuedEvent event = i.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.error("An exception occurred while performing user request", t); final FacesContext fc = FacesContext.getCurrentInstance(); final Map<String, Object> requestMap = fc.getExternalContext().getRequestMap(); final NavigationHandler nav = fc.getApplication().getNavigationHandler(); HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest(); Object servletEx = request.getAttribute("javax.servlet.error.exception"); try { if (servletEx instanceof SanitizationException) { fc.addMessage("errorMessage", new FacesMessage(FacesMessage.SEVERITY_ERROR, MessageConstant.EXCEPTION_MSG, "")); requestMap.put("exceptionMessage", ((SanitizationException) servletEx).getMessage()); nav.handleNavigation(fc, null, NavigationConstant.CUSTOM_ERROR_XHTML); } else if (t instanceof ViewExpiredException) { fc.addMessage("loginErrors", new FacesMessage(FacesMessage.SEVERITY_ERROR, MessageConstant.SESSION_EXPIRED_MSG, "")); nav.handleNavigation(fc, null, NavigationConstant.LOGIN_XHTML); } else { fc.addMessage("errorMessage", new FacesMessage(FacesMessage.SEVERITY_ERROR, MessageConstant.EXCEPTION_MSG, "")); requestMap.put("exceptionMessage", t.getMessage()); fc.getExternalContext().invalidateSession(); nav.handleNavigation(fc, null, NavigationConstant.CUSTOM_ERROR_XHTML); } fc.renderResponse(); } finally { i.remove(); } } getWrapped().handle(); }