package test_domain.RESTEASY_519_reproducer.mapper;

import javax.inject.Named;
import javax.inject.Singleton;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException;

import test_domain.RESTEASY_519_reproducer.domain.ErrorType;


/**
 * @author amoussa 
 * Work arround for the RESTEASY-519
 * Please uncomment the @Provider exception if you would like to enable the exception Mapper
 */
@Singleton
@Provider
@Named("JAXBMarshalMapper")
public class JaxBMarshalExceptionMapper implements ExceptionMapper<JAXBMarshalException>
{
	
	@Override
	public Response toResponse(JAXBMarshalException exception)
	{
		ErrorType phraseError = new ErrorType();
		phraseError.setType("400");
		phraseError.setMessage("BAD REQUEST FORMAT!");
		return Response.status(Status.BAD_REQUEST).build();
	}
}
