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

net.leanix.dropkit.InvalidEntityMapper Maven / Gradle / Ivy

There is a newer version: 2.0.10
Show newest version
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