0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

getLastErrorDetailed() for C++ client

This commit is contained in:
dwight 2009-09-14 12:31:47 -04:00
parent 8d07d50c48
commit 68c24f3595
2 changed files with 11 additions and 2 deletions

View File

@ -139,9 +139,14 @@ namespace mongo {
BSONObj getlasterrorcmdobj = fromjson("{getlasterror:1}");
string DBClientWithCommands::getLastError() {
BSONObj DBClientWithCommands::getLastErrorDetailed() {
BSONObj info;
runCommand("admin", getlasterrorcmdobj, info);
return info;
}
string DBClientWithCommands::getLastError() {
BSONObj info = getLastErrorDetailed();
BSONElement e = info["err"];
if( e.eoo() ) return "";
if( e.type() == Object ) return e.toString();

View File

@ -363,9 +363,13 @@ namespace mongo {
bool createCollection(const string &ns, unsigned size = 0, bool capped = false, int max = 0, BSONObj *info = 0);
/** Get error result from the last operation on this connection.
@return error or empty string if no error.
@return error message text, or empty string if no error.
*/
string getLastError();
/** Get error result from the last operation on this connection.
@return full error object.
*/
BSONObj getLastErrorDetailed();
/** Return the last error which has occurred, even if not the very last operation.