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

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

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

import io.dropwizard.jersey.validation.ValidationErrorMessage;

import javax.validation.ConstraintViolationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

@Provider
public class ValidacionExceptionMapper implements ExceptionMapper {
    private static final int BAD_REQUEST = 400;

    @Override
    public Response toResponse(ConstraintViolationException exception) {
        final ValidationErrorMessage message = new ValidationErrorMessage(exception.getConstraintViolations());

        return Response.status(BAD_REQUEST)
                .entity(message)
                .build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy