use of org.postgresql.util.PSQLException in project cloudbreak by hortonworks.
the class SqlUtil method getProperSqlErrorMessage.
public static String getProperSqlErrorMessage(DataIntegrityViolationException ex) {
Throwable cause = ex.getCause();
while (cause.getCause() != null || cause instanceof PSQLException) {
if (cause instanceof PSQLException && !((SQLException) cause).getSQLState().isEmpty()) {
PSQLException e = (PSQLException) cause;
String[] split = e.getLocalizedMessage().split("\\n");
if (split.length > 0) {
return split[0];
}
}
cause = cause.getCause();
}
return ex.getLocalizedMessage();
}
Aggregations