// Path: src/main/java/com/github/marcelothebuilder/webpedidos/service/NegocioException.java
// public class NegocioException extends RuntimeException {
// 	private static final long serialVersionUID = 1L;
// 
// 	public NegocioException() {
// 		super();
// 	}
// 
// 	public NegocioException(String message) {
// 		super(message);
// 	}
// 
// 	public NegocioException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 	public NegocioException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// }


import java.io.IOException;
import java.util.Iterator;
import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
import javax.faces.application.ViewExpiredException;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerWrapper;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ExceptionQueuedEvent;
import javax.faces.event.ExceptionQueuedEventContext;
import javax.inject.Inject;
import org.apache.commons.logging.Log;
import com.github.marcelothebuilder.webpedidos.service.NegocioException;
			try {
				NegocioException negException = getNegocioExceptionFromStack(exception);
				if (negException != null) {
					FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
							negException.getLocalizedMessage(), negException.getLocalizedMessage());

					FacesContext fc = FacesContext.getCurrentInstance();
					
					fc.addMessage(null, message);
					
				} else if (exception instanceof ViewExpiredException) {
					redirect("/");
				} else {
					redirect("/Erro.xhtml");
					log.error("Erro de sistema: " + exception.getMessage(), exception);
				}

				handled = true;

			} finally {
				if (handled) {
					exQueuedEventsIterator.remove();
				}
			}
		}

		this.getWrapped().handle();
	}

	private NegocioException getNegocioExceptionFromStack(Throwable exception) {
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/service/NegocioException.java
// public class NegocioException extends RuntimeException {
// 	private static final long serialVersionUID = 1L;
// 
// 	public NegocioException() {
// 		super();
// 	}
// 
// 	public NegocioException(String message) {
// 		super(message);
// 	}
// 
// 	public NegocioException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 	public NegocioException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// }


// Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/jsf/JsfExceptionHandlerWrapper.java
import java.io.IOException;
import java.util.Iterator;
import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
import javax.faces.application.ViewExpiredException;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerWrapper;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ExceptionQueuedEvent;
import javax.faces.event.ExceptionQueuedEventContext;
import javax.inject.Inject;
import org.apache.commons.logging.Log;
import com.github.marcelothebuilder.webpedidos.service.NegocioException;

			try {
				NegocioException negException = getNegocioExceptionFromStack(exception);
				if (negException != null) {
					FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
							negException.getLocalizedMessage(), negException.getLocalizedMessage());

					FacesContext fc = FacesContext.getCurrentInstance();
					
					fc.addMessage(null, message);
					
				} else if (exception instanceof ViewExpiredException) {
					redirect("/");
				} else {
					redirect("/Erro.xhtml");
					log.error("Erro de sistema: " + exception.getMessage(), exception);
				}

				handled = true;

			} finally {
				if (handled) {
					exQueuedEventsIterator.remove();
				}
			}
		}

		this.getWrapped().handle();
	}

	private NegocioException getNegocioExceptionFromStack(Throwable exception) {
		if (exception instanceof NegocioException) {