Exceptions throws for GLE should contain the entire GLE document

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Major - P3
    • 2.11.0
    • Affects Version/s: 2.10.1
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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}
      

              Assignee:
              Jeffrey Yemin
              Reporter:
              Jeffrey Yemin
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: