-
Type: Question
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 2.2.0
-
Component/s: Internal Client
-
Environment:Windows 7 64 SP1 MongoDB 2.2.0 C++ driver MSVS 2010
-
Fully Compatible
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; }}}
But it doesn't get caught. Instead it asserts:
{{Sun Dec 09 16:04:28 Assertion: 13111:wrong type for field (a_string) 2 != 1
Sun Dec 09 16:04:28 dev: lastError==0 won't report: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!