[SERVER-7889] Handling data type errors with UserException in MongoDB with the C++ driver Created: 10/Dec/12 Updated: 11/Jul/16 Resolved: 09/Jul/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Client |
| Affects Version/s: | 2.2.0 |
| Fix Version/s: | 2.5.1 |
| Type: | Question | Priority: | Minor - P4 |
| Reporter: | George Thompson | Assignee: | Matt Kangas |
| Resolution: | Done | Votes: | 0 |
| Labels: | pull-request | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 7 64 SP1 MongoDB 2.2.0 C++ driver MSVS 2010 |
||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Participants: | |||||||||
| Description |
|
According to: Double() (and like functions) should "throw a UserException if the element is not of the required type." My code: {{ BSONObj a_document = BSON("a_string"<<"A string"); try { a_document["a_string"].Double(); }catch(mongo::UserException ue) { cout << ue.toString() << endl; }}} {{Sun Dec 09 16:04:28 Assertion: 13111:wrong type for field (a_string) 2 != 1 My reading of bsonelement.h indicates it is throwing a MsgAssertionException – see line 472. Is the documentation or my understanding incorrect? Thanks! |
| Comments |
| Comment by Matt Kangas [ 09/Jul/13 ] |
|
Merged in 0e4a3a0c8 |
| Comment by auto [ 09/Jul/13 ] |
|
Author: {u'username': u'daveh86', u'name': u'daveh86', u'email': u'howsdav@gmail.com'}Message: Change the documented exception thrown by all instances of chk() from Signed-off-by: Matt Kangas <matt.kangas@10gen.com> |
| Comment by Daniel Pasette (Inactive) [ 19/Dec/12 ] |
|
The assertion type was changed but not the code's documentation with this commit: https://github.com/mongodb/mongo/commit/f91b04bd34fbbcbdfb3ca0ed06d530068c9205d6 Just need to match them up. |
| Comment by David Hows [ 19/Dec/12 ] |
|
Hi Gegorge, Your understanding is correct, it throws a MsgAssertionException. I have raised Cheers, David |