public static RequestProcessingException getDetailedExceptionFromSql()

in src/main/java/com/epam/digital/data/platform/restapi/core/utils/SQLExceptionResolverUtil.java [47:64]


  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);
    }
  }