org.kiwiproject.dropwizard.util.exception.JerseyViolationExceptionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dropwizard-service-utilities Show documentation
Show all versions of dropwizard-service-utilities Show documentation
Set of utilities to aid in setting up Dropwizard services
package org.kiwiproject.dropwizard.util.exception;
import io.dropwizard.jersey.validation.JerseyViolationException;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
import org.kiwiproject.jaxrs.exception.ConstraintViolationExceptionMapper;
import org.kiwiproject.jaxrs.exception.JaxrsException;
import org.kiwiproject.jaxrs.exception.JaxrsExceptionMapper;
/**
* Override default Dropwizard mapper to use kiwi's {@link org.kiwiproject.jaxrs.exception.ErrorMessage ErrorMessage}.
* The response entity is built using {@link JaxrsExceptionMapper#buildResponseEntity(JaxrsException)}.
*/
@Provider
public class JerseyViolationExceptionMapper implements ExceptionMapper {
@Override
public Response toResponse(JerseyViolationException exception) {
return ConstraintViolationExceptionMapper.buildResponse(exception.getConstraintViolations());
}
}