net.leanix.dropkit.InvalidEntityMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leanix-dropkit Show documentation
Show all versions of leanix-dropkit Show documentation
Base functionality for leanIX dropwizard-based services
package net.leanix.dropkit;
import javax.validation.ConstraintViolationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import net.leanix.dropkit.responses.BasicResponse;
/**
*
* @link http://stackoverflow.com/questions/24573028/dropwizard-custom-exception-for-invalidentityexception
*/
@Provider
public class InvalidEntityMapper implements ExceptionMapper {
/**
*
* @param ex
* @return
*/
@Override
public Response toResponse(ConstraintViolationException ex) {
return Response.status(422)
.entity(new BasicResponse(ex))
.type("text/json")
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy