Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-4219

Error Code from WriteError not propagated to MongoServerException

    XMLWordPrintableJSON

Details

    • Fully Compatible
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

    Description

      The current driver 4.3.0-beta3 does not seem to propagate the error code from the WriteError to the MongoWriteException in case of an E11000.

      With 4.2 drivers the error code matched.

      try {
      	MongoCollection<org.bson.Document> collection = client.getDatabase("test").getCollection("write-error-tests");
      	collection.insertOne(new org.bson.Document("_id", "id-1"));
      	collection.insertOne(new org.bson.Document("_id", "id-1"));
      } catch (MongoServerException e) {
      	System.out.println("ServerException Code: " + e.getCode());
      	System.out.println("WriteError Code     : " + ((MongoWriteException)e).getError().getCode());
      }
      

      Attachments

        Activity

          People

            jeff.yemin@mongodb.com Jeffrey Yemin
            cstrobl Christoph Strobl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: