All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ec.gob.senescyt.sniese.commons.exceptions.mappers.JsonMappingExceptionMapper Maven / Gradle / Ivy

There is a newer version: 2.0.5
Show newest version
package ec.gob.senescyt.sniese.commons.exceptions.mappers;

import com.fasterxml.jackson.databind.JsonMappingException;
import ec.gob.senescyt.sniese.commons.core.Errores;
import ec.gob.senescyt.sniese.commons.core.MensajeError;
import org.eclipse.jetty.http.HttpStatus;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;

public class JsonMappingExceptionMapper implements ExceptionMapper{
    @Override
    public Response toResponse(JsonMappingException exception) {
        Errores errores = new Errores();
        errores.agregar(new MensajeError("ErrorFormato",String.format("Formato inválido [%s]",exception.getPathReference())));
        return Response.status(HttpStatus.BAD_REQUEST_400).entity(errores).build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy