代码如下:
try
{
mongo::DBClientConnection * conn = new DBClientConnection(true, 0, 3);
if(!conn->isFailed())
{
cout<<"-false"<<" type:"<< conn->type()<<endl;
}
else
cout<<"-true"<<" type:"<< conn->type()<<endl;
//初始化连接
MongoDB_Connect(&conn);
if(conn->isFailed())
{
cout<<"1:连接失败!"<<" type:"<< conn->type()<<endl;
}
else
cout<<"2:连接成功!"<< conn->toString()<<" type:"<< conn->type()<<endl;
BSONArrayBuilder c;
BSONObjBuilder add,A,B;
int falg = 401;
B.append("trans_sub_typecode",falg);
B.append("discouant_money","0");
B.append("account_money","0");
B.append("proxy_money","0");
c.append("0");
c.append("0.00");
B.append("trans_amount",BSON("$nin"<<c.arr()));
auto_ptr<DBClientCursor> cursor;
Query query(B.obj());
try
{
cursor = conn->query("e_invoice.issue_park_transactions",query);
}
catch (mongo::AssertionException &e1)
{
printf("0:捕获异常: %s\n", e1.what());
}
catch (mongo::SocketException &e1)
{
printf("1:捕获异常: %s\n", e1.what());
}
catch (mongo::DBException &e1)
{
printf("2:捕获异常: %s\n", e1.what());
}
catch (mongo::exception &e1)
{
printf("02:捕获异常: %s\n", e1.what());
}
catch (...)
{
printf("查询失败 数据库数据异常\n");
}
if(cursor.get() == NULL)
{
cout<<"--返回为NULL:"<< conn->type()<<endl;
}
if(conn->isFailed())
{
cout<<"2:连接失败!"<<" type:"<< conn->type()<<endl;
}
else
cout<<"2:连接成功!"<< conn->toString()<<" type:"<< conn->type()<<endl;
}
catch (mongo::SocketException &e1)
{
printf("3:捕获异常: %s\n", e1.what());
}
catch (mongo::DBException &e1)
{
printf("3:捕获异常: %s\n", e1.what());
}
catch (...)
{
printf("3:查询失败 数据库数据异常\n");
}
执行结果:
我想要获取这段异常,有人有了解么?