-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.10.1
-
Component/s: 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}
- is depended on by
-
DRIVERS-75 Exceptions throws for GLE should contain the entire GLE document
- Closed
- is related to
-
JAVA-517 DuplicateKey exception not properly thrown through findAndModify
- Closed