code: MolgenisValidationException translateNotNullViolation(PSQLException pSqlException) {
      ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage();
      String tableName = serverErrorMessage.getTable();
      String message = serverErrorMessage.getMessage();
      Matcher matcher =
          Pattern.compile("null value in column \"?(.*?)\"? violates not-null constraint")
              .matcher(message);
      boolean matches = matcher.matches();
      if (matches) {
        // exception message when adding data that does not match constraint
        String columnName = matcher.group(1);
  
        EntityTypeDescription entityTypeDescription =
            entityTypeRegistry.getEntityTypeDescription(tableName);
        entityTypeDescription.getAttributeDescriptionMap().get(columnName);
  
        ConstraintViolation constraintViolation =
            new ConstraintViolation(
                format(
                    "The attribute '%s' of entity '%s' can not be null.",
                    tryGetAttributeName(tableName, columnName).orElse(TOKEN_UNKNOWN),
                    tryGetEntityTypeName(tableName).orElse(TOKEN_UNKNOWN)),
                null);
        return new MolgenisValidationException(singleton(constraintViolation));
      } else {
        // exception message when applying constraint on existing data
        matcher = Pattern.compile("column \"(.*?)\" contains null values").matcher(message);
        matches = matcher.matches();
        if (!matches) {
          throw new RuntimeException(ERROR_TRANSLATING_EXCEPTION_MSG, pSqlException);
        }
        String columnName = matcher.group(1);
  
        ConstraintViolation constraintViolation =
            new ConstraintViolation(
                format(
                    "The attribute '%s' of entity '%s' contains null values.",
                    tryGetAttributeName(tableName, columnName).orElse(TOKEN_UNKNOWN),
                    tryGetEntityTypeName(tableName).orElse(TOKEN_UNKNOWN)),
                null);
        return new MolgenisValidationException(singleton(constraintViolation));
      }
    }
docs: Package private for testability
  
  @param pSqlException PostgreSQL exception
  @return translated validation exception