class DataValidationExceptionMapper implements ExceptionMapper<DataValidationException> {

    @Override
    public Response toResponse(DataValidationException e) {
        return Response.status(400)
                .type(MediaType.APPLICATION_JSON_TYPE)
                .entity(ImmutableMap.of("code", 400, "message", e.getMessage(), "errors", e.getErrors()))
                .build();
    }

}