<commit_before>package ro.satrapu.homebudget.ui.exceptionhandler;

import java.util.Iterator;
import javax.faces.FacesException;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ExceptionQueuedEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Handles uncaught exceptions.
 * <br/>
 * This class is based on an article found 
 * <a href="http://javalabor.blogspot.com/2011/09/jsf-2-global-exception-handling.html">here</a>.
 * @author satrapu
 */
public class ExceptionHandler
        extends javax.faces.context.ExceptionHandlerWrapper {

    private final Logger logger = LoggerFactory.getLogger(getClass());
    private javax.faces.context.ExceptionHandler wrapped;

    public ExceptionHandler(final javax.faces.context.ExceptionHandler wrapped) {
        this.wrapped = wrapped;
    }

    @Override
    public javax.faces.context.ExceptionHandler getWrapped() {
        return wrapped;
    }

    @Override
    public void handle() throws FacesException {
        for (final Iterator<ExceptionQueuedEvent> it = getUnhandledExceptionQueuedEvents().iterator(); it.hasNext();) {
            Throwable throwable = it.next().getContext().getException();
            logger.error("Caught an unexpected exception", throwable);

            FacesContext facesContext = FacesContext.getCurrentInstance();
            ExternalContext externalContext = facesContext.getExternalContext();
            externalContext.getSessionMap().put("unexpectedErrorDetails", ExceptionPrettyPrinter.prettyPrint(throwable));

            try {
                String url = externalContext.getRequestContextPath() + "/faces/errors/unexpectedError.xhtml";
                externalContext.redirect(url);
            } catch (Exception ex) {
                logger.error("Could not redirect user to error page", ex);
            } finally {
                it.remove();
            }
        }<commit_msg>Replaced SLF4J factory call with logging producer static method call.<commit_after>package ro.satrapu.homebudget.ui.exceptionhandler;

import java.util.Iterator;
import javax.faces.FacesException;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ExceptionQueuedEvent;
import org.slf4j.Logger;
import ro.satrapu.homebudget.services.logging.LoggerProducer;

/**
 * Handles uncaught exceptions. <br/> This class is based on an article found <a
 * href="http://javalabor.blogspot.com/2011/09/jsf-2-global-exception-handling.html"> here</a>.
 *
 * @author satrapu
 */
public class ExceptionHandler extends javax.faces.context.ExceptionHandlerWrapper {

    private static final Logger logger = LoggerProducer.produce(ExceptionHandler.class);
    private javax.faces.context.ExceptionHandler wrapped;

    public ExceptionHandler(final javax.faces.context.ExceptionHandler wrapped) {
        this.wrapped = wrapped;
    }

    @Override
    public javax.faces.context.ExceptionHandler getWrapped() {
        return wrapped;
    }

    @Override
    public void handle() throws FacesException {
        for (final Iterator<ExceptionQueuedEvent> it = getUnhandledExceptionQueuedEvents().iterator(); it.hasNext();) {
            Throwable throwable = it.next().getContext().getException();
            logger.error("Caught an unexpected exception", throwable);

            FacesContext facesContext = FacesContext.getCurrentInstance();
            ExternalContext externalContext = facesContext.getExternalContext();
            externalContext.getSessionMap().put("unexpectedErrorDetails", ExceptionPrettyPrinter.prettyPrint(throwable));

            try {
                String url = externalContext.getRequestContextPath() + "/faces/errors/unexpectedError.xhtml";
                externalContext.redirect(url);
            } catch (Exception ex) {
                logger.error("Could not redirect user to error page", ex);
            } finally {
                it.remove();
            }
        }
{'fraction_non_alphanumeric': 0.10002488181139586, 'fraction_numerical': 0.004478726051256532, 'mean_word_length': 3.276595744680851, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3836996', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1013, 'n_words': 219}