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

Error Code from WriteError not propagated to MongoServerException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.3.0
    • Component/s: Error Handling
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Documentation Changes:
      Not Needed

      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

            Assignee:
            jeff.yemin Jeffrey Yemin
            Reporter:
            cstrobl Christoph Strobl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: