[CSHARP-299] MongoQueryException should provide response document that caused it Created: 05/Aug/11  Updated: 02/Apr/15  Resolved: 05/Aug/11

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.2
Fix Version/s: 1.2

Type: Improvement Priority: Major - P3
Reporter: Aristarkh Zagorodnikov Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: exception, query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible

 Description   

Currently, MongoQueryException only stores the message string. For our internal error handling mechanism it would be much better if it provided access to the response document.
MongoCommandException, for example, has the ability to store CommandResult, and having something like QueryResult, containing the response document would be very good.
I think this will be a good addition for everyone to use, at least to be able to do detailed logging.

Currently, because there is no access to the response document we have to do error testing in the following way (yes, this code smells, but there's no choice right now) :
catch (MongoQueryException exception)

{ if (exception.Message.Contains("\"code\" : 13435 }

"))

{ ... }

}



 Comments   
Comment by Aristarkh Zagorodnikov [ 08/Aug/11 ]

Thanks a lot!

Comment by Robert Stam [ 05/Aug/11 ]

Implemented.

Generated at Wed Feb 07 21:36:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.