Windows 7 64 SP1 MongoDB 2.2.0 C++ ドライバー MSVS 2010
によると:
Double()
(および同様の関数)は、「UserException
要素が必要なタイプでない場合にスローする」必要があります。
私のコード:
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
Sun Dec 09 16:04:28 dev: lastError==0 won't report:wrong type for field (a_string) 2 != 1
私は何を間違っていますか?データ型の例外を自分でキャッチして処理したい。
ありがとう!