use of org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent in project deltaspike by apache.
the class BridgeExceptionHandlerWrapper method processEvent.
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
//needed because #handle gets called too late in this case
if (event instanceof ExceptionQueuedEvent) {
ExceptionQueuedEvent exceptionQueuedEvent = (ExceptionQueuedEvent) event;
FacesContext facesContext = exceptionQueuedEvent.getContext().getContext();
if (facesContext.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE && exceptionQueuedEvent.getContext().inBeforePhase()) {
Throwable exception = getRootCause(exceptionQueuedEvent.getContext().getException());
if (exception instanceof AccessDeniedException) {
processAccessDeniedException(exception);
} else {
ExceptionToCatchEvent exceptionToCatchEvent = new ExceptionToCatchEvent(exception);
exceptionToCatchEvent.setOptional(true);
this.beanManager.fireEvent(exceptionToCatchEvent);
if (exceptionToCatchEvent.isHandled()) {
return;
}
}
}
}
super.processEvent(event);
}
use of org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent in project deltaspike by apache.
the class TraversalPathTest method testTraversalPathOrder.
/**
* Tests SEAMCATCH-32, see JIRA for more information about this test. https://issues.jboss.org/browse/SEAMCATCH-32
*/
@Test
public void testTraversalPathOrder() {
// create an exception stack E1 -> E2 -> E3
Exceptions.Exception1 exception = new Exceptions.Exception1(new Exceptions.Exception2(new Exceptions.Exception3()));
manager.fireEvent(new ExceptionToCatchEvent(exception));
/*
handleException3SuperclassBF
handleException3BF
handleException3DF
handleException3SuperclassDF
handleException2BF
handleException2DF
handleException1BF
handleException1DF
*/
Object[] expectedOrder = { 1, 2, 3, 4, 5, 6, 7, 8 };
assertArrayEquals(expectedOrder, ExceptionHandlerMethods.getExecutionorder().toArray());
}
use of org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent in project deltaspike by apache.
the class CallingHandlersTest method assertProtectedHandlersAreCalled.
@Test
public void assertProtectedHandlersAreCalled() {
bm.fireEvent(new ExceptionToCatchEvent(new IllegalStateException()));
assertTrue(calledExceptionHandler.isProtectedHandlerCalled());
}
use of org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent in project tomee by apache.
the class OSValidator method validOS.
public void validOS(final String os) {
if (os.toLowerCase().contains("win")) {
// can be a caugh exceptino
final Exception ex = new OSRuntimeException();
exceptionEvent.fire(new ExceptionToCatchEvent(ex));
}
}
use of org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent in project deltaspike by apache.
the class UnMuteHandlerTest method assertCorrectNumberOfCallsForUnMute.
@Test
public void assertCorrectNumberOfCallsForUnMute() {
bm.fireEvent(new ExceptionToCatchEvent(new Exception(new NullPointerException())));
assertEquals(2, unMuteHandler.getDepthFirstNumberCalled());
assertEquals(2, unMuteHandler.getBreadthFirstNumberCalled());
}
Aggregations