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

Exceptions throws for GLE should contain the entire GLE document

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.11.0
    • 2.10.1
    • None
    • None

    Description

      Currently, you get the code and the err fields from the result document, and the code is not included in the exception message so it's generally lost.

      To fix, adding a new MongoException subclass called WriteConcernException, which DuplicateKey now extends. WriteConcernException takes the command result and passes toString() of it to MongoException, so the JSON representation of the entire document will appear in logs, e.g.

      com.mongodb.MongoException$DuplicateKey: { 
        "serverUsed" : "/127.0.0.1:27017" ,
        "err" : "E11000 duplicate key error index:    
                 com_mongodb_unittest_DBCollectionTest.testDuplicateKey.$_id_ 
                 dup key: { : ObjectId('511a75c1eaa895f019e01b78') }" , 
        "code" : 11000 , 
        "n" : 0 , 
        "connectionId" : 76 , 
        "ok" : 1.0}

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: