in src/main/java/com/epam/digital/data/platform/kafkaapi/core/util/SQLExceptionResolverUtil.java [48:65]
public static RequestProcessingException getDetailedExceptionFromSql(SQLException exception) {
String sqlState = exception.getSQLState();
String shortErrorDescription = Optional.ofNullable(exception.getMessage())
.map(message -> message.split("\n")[0])
.orElse("");
boolean isConstraintViolation = sqlErrorCodeToDetail.containsKey(sqlState);
if (isConstraintViolation) {
return new ConstraintViolationException(
"Constraint violation occurred: " + shortErrorDescription,
exception,
sqlErrorCodeToDetail.get(sqlState));
} else if (PERMISSION_DENIED_ERROR_CODE.equals(sqlState)) {
return new ForbiddenOperationException("User has invalid role for this operation");
} else {
return new ProcedureErrorException(
"Procedure error on DB call occurred: " + shortErrorDescription, exception);
}
}