Throwable throwable = unhandledExceptionQueuedEvents.next().getContext().getException();
public void processEvent(SystemEvent exceptionQueuedEvent) { Throwable throwable = ((ExceptionQueuedEvent) exceptionQueuedEvent) .getContext().getException(); if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, "Exception during window disposal " + throwable); } }
@Override public void handle() throws FacesException { Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); while (i.hasNext()) { ExceptionQueuedEvent event = i.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); // get the exception from context Throwable t = context.getException(); if (NonexistentConversationException.class.isInstance(t)) { i.remove(); throw RuntimeException.class.cast(t); } } delegate.handle(); } }
protected Throwable getJSF2HandledException(FacesContext facesContext) { Throwable handledException = null; ExceptionHandler exceptionHandler = facesContext.getExceptionHandler(); Iterable<ExceptionQueuedEvent> handledExceptionQueuedEvents = exceptionHandler.getHandledExceptionQueuedEvents(); if (handledExceptionQueuedEvents != null) { Iterator<ExceptionQueuedEvent> itr = handledExceptionQueuedEvents.iterator(); while (itr.hasNext()) { ExceptionQueuedEvent exceptionQueuedEvent = itr.next(); ExceptionQueuedEventContext exceptionQueuedEventContext = exceptionQueuedEvent.getContext(); handledException = exceptionQueuedEventContext.getException(); break; } } return handledException; }
protected Throwable getJSF2UnhandledException(FacesContext facesContext) { Throwable unhandledException = null; ExceptionHandler exceptionHandler = facesContext.getExceptionHandler(); Iterable<ExceptionQueuedEvent> unhandledExceptionQueuedEvents = exceptionHandler.getUnhandledExceptionQueuedEvents(); if (unhandledExceptionQueuedEvents != null) { Iterator<ExceptionQueuedEvent> itr = unhandledExceptionQueuedEvents.iterator(); while (itr.hasNext()) { ExceptionQueuedEvent exceptionQueuedEvent = itr.next(); ExceptionQueuedEventContext exceptionQueuedEventContext = exceptionQueuedEvent.getContext(); unhandledException = exceptionQueuedEventContext.getException(); break; } } return unhandledException; }
protected Throwable getJSF2HandledException(FacesContext facesContext) { Throwable handledException = null; ExceptionHandler exceptionHandler = facesContext.getExceptionHandler(); Iterable<ExceptionQueuedEvent> handledExceptionQueuedEvents = exceptionHandler.getHandledExceptionQueuedEvents(); if (handledExceptionQueuedEvents != null) { Iterator<ExceptionQueuedEvent> itr = handledExceptionQueuedEvents.iterator(); while (itr.hasNext()) { ExceptionQueuedEvent exceptionQueuedEvent = itr.next(); ExceptionQueuedEventContext exceptionQueuedEventContext = exceptionQueuedEvent.getContext(); handledException = exceptionQueuedEventContext.getException(); break; } } return handledException; }
protected Throwable getJSF2UnhandledException(FacesContext facesContext) { Throwable unhandledException = null; ExceptionHandler exceptionHandler = facesContext.getExceptionHandler(); Iterable<ExceptionQueuedEvent> unhandledExceptionQueuedEvents = exceptionHandler.getUnhandledExceptionQueuedEvents(); if (unhandledExceptionQueuedEvents != null) { Iterator<ExceptionQueuedEvent> itr = unhandledExceptionQueuedEvents.iterator(); while (itr.hasNext()) { ExceptionQueuedEvent exceptionQueuedEvent = itr.next(); ExceptionQueuedEventContext exceptionQueuedEventContext = exceptionQueuedEvent.getContext(); unhandledException = exceptionQueuedEventContext.getException(); break; } } return unhandledException; }
public void handle() throws FacesException { final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); while (i.hasNext()) { ExceptionQueuedEvent event = i.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); final FacesContext fc = FacesContext.getCurrentInstance(); final ExternalContext externalContext = fc.getExternalContext(); final ConfigurableNavigationHandler nav = (ConfigurableNavigationHandler) fc.getApplication().getNavigationHandler(); try { log.error(t.getMessage(), t); performRedirect(externalContext, "/error_service.htm"); fc.renderResponse(); } finally { i.remove(); } } getWrapped().handle(); }
@Override public void handle() throws FacesException { FacesContext facesContext = FacesContext.getCurrentInstance(); ExceptionQueuedEventContext exceptionContext; Throwable root; for (Iterator<ExceptionQueuedEvent> iter = getUnhandledExceptionQueuedEvents().iterator(); iter.hasNext();) { exceptionContext = (ExceptionQueuedEventContext) iter.next().getSource(); root = getRoot(exceptionContext.getException()); if (handleException(root, facesContext)) { iter.remove(); } } if (getUnhandledExceptionQueuedEvents().iterator().hasNext()) { getWrapped().handle(); } }
/** * Set every exception as a global FATAL faces message. */ @Override public void handle() { for (Iterator<ExceptionQueuedEvent> iter = getUnhandledExceptionQueuedEvents().iterator(); iter.hasNext();) { addGlobal(new FacesMessage(SEVERITY_FATAL, createFatalMessage(iter.next().getContext().getException()), null)); iter.remove(); } getWrapped().handle(); }
private void log(ExceptionQueuedEventContext exceptionContext) { UIComponent c = exceptionContext.getComponent(); boolean beforePhase = exceptionContext.inBeforePhase(); boolean afterPhase = exceptionContext.inAfterPhase(); PhaseId phaseId = exceptionContext.getPhaseId(); Throwable t = exceptionContext.getException(); String key = getLoggingKey(beforePhase, afterPhase); if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, key, new Object[] { t.getClass().getName(), phaseId.toString(), ((c != null) ? c.getClientId(exceptionContext.getContext()) : ""), t.getMessage()}); LOGGER.log(Level.SEVERE, t.getMessage(), t); } }
/** * Set every exception as a global FATAL faces message. */ @Override public void handle() { for (Iterator<ExceptionQueuedEvent> iter = getUnhandledExceptionQueuedEvents().iterator(); iter.hasNext();) { addGlobal(new FacesMessage(SEVERITY_FATAL, createFatalMessage(iter.next().getContext().getException()), null)); iter.remove(); } getWrapped().handle(); }
/** * @param context * @throws Throwable */ private void handleException(FacesContext context) { Iterator<ExceptionQueuedEvent> unhandledExceptionQueuedEvents = getUnhandledExceptionQueuedEvents().iterator(); if (unhandledExceptionQueuedEvents.hasNext()) { Throwable exception = unhandledExceptionQueuedEvents.next().getContext().getException(); unhandledExceptionQueuedEvents.remove(); Throwable rootCause = Exceptions.unwrap(exception); if (rootCause instanceof BusinessException) { handleBusinessException(context, (BusinessException) rootCause); return; } //send user to error page when unexpected exceptions are raised goToErrorPage(context, rootCause); } }
/** * @param context * @throws Throwable */ private void handleException(FacesContext context) { Iterator<ExceptionQueuedEvent> unhandledExceptionQueuedEvents = getUnhandledExceptionQueuedEvents().iterator(); if (unhandledExceptionQueuedEvents.hasNext()) { Throwable exception = unhandledExceptionQueuedEvents.next().getContext().getException(); unhandledExceptionQueuedEvents.remove(); Throwable rootCause = Exceptions.unwrap(exception); if (rootCause instanceof BusinessException) { handleBusinessException(context, (BusinessException) rootCause); return; } //send user to error page when unexpected exceptions are raised goToErrorPage(context, rootCause); } }
private void log(ExceptionQueuedEventContext exceptionContext) { UIComponent c = exceptionContext.getComponent(); boolean beforePhase = exceptionContext.inBeforePhase(); boolean afterPhase = exceptionContext.inAfterPhase(); PhaseId phaseId = exceptionContext.getPhaseId(); Throwable t = exceptionContext.getException(); String key = getLoggingKey(beforePhase, afterPhase); if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, key, new Object[] { t.getClass().getName(), phaseId.toString(), ((c != null) ? c.getClientId(exceptionContext.getContext()) : ""), t.getMessage()}); LOGGER.log(Level.SEVERE, t.getMessage(), t); } }
private void log(ExceptionQueuedEventContext exceptionContext) { UIComponent c = exceptionContext.getComponent(); boolean beforePhase = exceptionContext.inBeforePhase(); boolean afterPhase = exceptionContext.inAfterPhase(); PhaseId phaseId = exceptionContext.getPhaseId(); Throwable t = exceptionContext.getException(); String key = getLoggingKey(beforePhase, afterPhase); if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, key, new Object[] { t.getClass().getName(), phaseId.toString(), ((c != null) ? c.getClientId(exceptionContext.getContext()) : ""), t.getMessage()}); LOGGER.log(Level.SEVERE, t.getMessage(), t); } }
private void log(ExceptionQueuedEventContext exceptionContext) { UIComponent c = exceptionContext.getComponent(); boolean beforePhase = exceptionContext.inBeforePhase(); boolean afterPhase = exceptionContext.inAfterPhase(); PhaseId phaseId = exceptionContext.getPhaseId(); Throwable t = exceptionContext.getException(); String key = getLoggingKey(beforePhase, afterPhase); if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, key, new Object[] { t.getClass().getName(), phaseId.toString(), ((c != null) ? c.getClientId(exceptionContext.getContext()) : ""), t.getMessage()}); LOGGER.log(Level.SEVERE, t.getMessage(), t); } }
public void afterPhase(PhaseEvent event) { FacesContext facesContext = event.getFacesContext(); // stop recording current phase time EtmPoint point = (EtmPoint) facesContext.getAttributes().get(CURRENT_PHASE_POINT); if (point != null) { // alter name if we encounter an exception Iterator<ExceptionQueuedEvent> it = facesContext.getExceptionHandler().getUnhandledExceptionQueuedEvents().iterator(); if (it.hasNext()) { ExceptionQueuedEvent exceptionQueuedEvent = it.next(); point.alterName(point.getName() + " [" + exceptionQueuedEvent.getContext().getException().getClass().getSimpleName() + "]"); } point.collect(); facesContext.getAttributes().remove(CURRENT_PHASE_POINT); } }
@SuppressWarnings("unchecked") private boolean handle(ExceptionQueuedEvent event) { Throwable exception = getRootCause(event.getContext().getException()); Class<? extends Throwable> exceptionType = exception.getClass(); for (ExceptionHandler handler : SpringFacesExceptionHandlerSupport.this.exceptionHandlers) { Class<?> handlerGeneric = GenericTypeResolver.resolveTypeArgument(handler.getClass(), ExceptionHandler.class); if (handlerGeneric == null || handlerGeneric.isAssignableFrom(exceptionType)) { try { if (handler.handle(exception, event)) { return true; } } catch (Exception e) { ReflectionUtils.rethrowRuntimeException(e); } } } return false; }
public void testGetView_ExceptionsOnPostRestoreStateEvent() { this.lifecycle = new NoExecutionLifecycle(this.jsfMock.lifecycle()); this.factory = new JsfViewFactory(this.parser.parseExpression(VIEW_ID, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)), this.lifecycle); MockUIViewRoot existingRoot = new MockUIViewRoot(); existingRoot.setThrowOnPostRestoreStateEvent(true); existingRoot.setViewId(VIEW_ID); ((MockViewHandler) this.viewHandler).setRestoreView(existingRoot); this.context.inViewState(); EasyMock.expectLastCall().andReturn(true); EasyMock.replay(this.context); this.factory.getView(this.context); ExceptionEventAwareMockApplication application = (ExceptionEventAwareMockApplication) FlowFacesContext .getCurrentInstance().getApplication(); assertNotNull("Expected exception event", application.getExceptionQueuedEventContext()); assertSame("Expected same exception", existingRoot.getAbortProcessingException(), application .getExceptionQueuedEventContext().getException()); }