code: MolgenisValidationException translateDependentObjectsStillExist(PSQLException pSqlException) {
      ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage();
      String detail = serverErrorMessage.getDetail();
      Matcher matcher =
          Pattern.compile(
                  "constraint (.+) on table \"?([^\"]+)\"? depends on table \"?([^\"]+)\"?\n?")
              .matcher(detail);
  
      Map<String, Set<String>> entityTypeDependencyMap = new LinkedHashMap<>();
      while (matcher.find()) {
        String tableName = matcher.group(2);
        String dependentTableName = matcher.group(3);
  
        String entityTypeName = tryGetEntityTypeName(tableName).orElse(TOKEN_UNKNOWN);
        String dependentEntityTypeName =
            tryGetEntityTypeName(dependentTableName).orElse(TOKEN_UNKNOWN);
        Set<String> dependentTableNames =
            entityTypeDependencyMap.computeIfAbsent(
                dependentEntityTypeName, k -> new LinkedHashSet<>());
        dependentTableNames.add(entityTypeName);
      }
  
      if (entityTypeDependencyMap.isEmpty()) // no matches
      {
        LOG.error(ERROR_TRANSLATING_POSTGRES_EXC_MSG, pSqlException);
        throw new RuntimeException(ERROR_TRANSLATING_EXCEPTION_MSG, pSqlException);
      }
  
      Set<ConstraintViolation> constraintViolations =
          entityTypeDependencyMap
              .entrySet()
              .stream()
              .map(
                  entry -> {
                    String message;
                    if (entry.getValue().size() == 1) {
                      message =
                          format(
                              "Cannot delete entity '%s' because entity '%s' depends on it.",
                              entry.getKey(), entry.getValue().iterator().next());
                    } else {
                      message =
                          format(
                              "Cannot delete entity '%s' because entities '%s' depend on it.",
                              entry.getKey(), entry.getValue().stream().collect(joining(", ")));
                    }
                    return new ConstraintViolation(message, null);
                  })
              .collect(toCollection(LinkedHashSet::new));
  
      return new MolgenisValidationException(constraintViolations);
    }
docs: Package private for testability
  
  @param pSqlException PostgreSQL exception
  @return translated validation exception