You must use an exception handler. Example:
@Provider
public class ValidationExceptionMapper implements ExceptionMapper<javax.validation.ConstraintViolationException> {
public Response toResponse(javax.validation.ConstraintViolationException cex) {
Error error = new Error();
error.setMessage("Whatever message you want to send to user. " + cex);
return Response.entity(error).status(400).build();
}
}
where the error might be something like this:
@XmlRootElement
public class Error{
private String message;
}
You will then receive an error message enclosed in XML.