@SuppressWarnings({"ThrowableInstanceNeverThrown"})
public void handle() throws FacesException {
for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext(); ) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
try {
Throwable t = context.getException();
if (isRethrown(t)) {
handled = event;
Throwable unwrapped = getRootCause(t);
if (unwrapped != null) {
throwIt(context.getContext(),
new FacesException(unwrapped.getMessage(), unwrapped));
} else {
if (t instanceof FacesException) {
throwIt(context.getContext(), (FacesException) t);
} else {
throwIt(context.getContext(),
new FacesException(t.getMessage(), t));
}
}
if (LOGGER.isLoggable(INCIDENT_ERROR)) {
log(context);