[JAVA-757] Exceptions throws for GLE should contain the entire GLE document Created: 12/Feb/13  Updated: 19/Mar/13  Resolved: 25/Feb/13

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 2.10.1
Fix Version/s: 2.11.0

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by DRIVERS-75 Exceptions throws for GLE should cont... Closed
Related
is related to JAVA-517 DuplicateKey exception not properly t... Closed

 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}



 Comments   
Comment by auto [ 14/Mar/13 ]

Author:

{u'date': u'2013-03-14T19:30:20Z', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-757: Reverting behavioral change to CommandResult.getException. It now returns null, as before, if there is no exception, instead of throwing IllegalStateException.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/84532013ef3048e7d8d0dc42df10207d71254f08

Comment by auto [ 22/Feb/13 ]

Author:

{u'date': u'2013-02-15T22:32:15Z', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-757: Made CommandFailureException public. Added Javadoc
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/2ed798f029bef844769b56e2aeff904c2e75aaee

Comment by auto [ 22/Feb/13 ]

Author:

{u'date': u'2013-02-13T02:36:20Z', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-757: Changing CommandFailureException and WriteConcernException from static inner class to top-level.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/7897a3bf4fe88cfc67769d291a026a87a0c27710

Comment by auto [ 22/Feb/13 ]

Author:

{u'date': u'2013-02-12T17:09:41Z', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-757: 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, instead of just the "err" field
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/046d662c42d586df8e28648ee2b56044bee16b2e

Generated at Thu Feb 08 08:53:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.