public static Response invalidEntity(ConstraintViolationException e){
  StringBuilder errorMessage=new StringBuilder();
  boolean firstPass=true;
  for (  ConstraintViolation error : e.getConstraintViolations()) {
    if (!firstPass) {
      errorMessage.append(", ");
    }
    errorMessage.append(String.format("%s %s (was %s)",error.getPropertyPath(),error.getMessage(),error.getInvalidValue()));
    firstPass=false;
  }
  ExternalException externalException=new ExternalException(ErrorCode.INVALID_ENTITY,errorMessage.toString(),null);
  return externalException(externalException);
}

public static Response invalidEntity ( ConstraintViolationException e ) { StringBuilder errorMessage = new StringBuilder ( ) ; boolean firstPass = true ; for ( ConstraintViolation error : e . getConstraintViolations ( ) ) { if ( ! firstPass ) { errorMessage . append ( ", " ) ; } errorMessage . append ( String . format ( "%s %s (was %s)" , error . getPropertyPath ( ) , error . getMessage ( ) , error . getInvalidValue ( ) ) ) ; firstPass = false ; } ExternalException externalException = new ExternalException ( ErrorCode . INVALID_ENTITY , errorMessage . toString ( ) , null ) ; return externalException ( externalException ) ; }
return an error response generated by a validation failure , invalid json , etc .
