ec.gob.senescyt.sniese.commons.exceptions.mappers.ValidacionExceptionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sniese-commons Show documentation
Show all versions of sniese-commons Show documentation
Librería que contiene clases de uso comun para sniese hechos en dropwizard
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