diff options
author | Spencer T Brody <spencer@10gen.com> | 2012-12-20 19:08:24 -0500 |
---|---|---|
committer | Spencer T Brody <spencer@10gen.com> | 2012-12-20 19:36:23 -0500 |
commit | 4f6a3339782456946d9423cb39ef9a243a76c4e4 (patch) | |
tree | 453df2992fd7235fb9e9e7c0c9e3720f1621ad4c /src/mongo/db/commands.cpp | |
parent | fdbf689f653c3dd203c5f57372dc1859d31600bc (diff) | |
download | mongo-4f6a3339782456946d9423cb39ef9a243a76c4e4.tar.gz |
Call setLastError when commands fail
Diffstat (limited to 'src/mongo/db/commands.cpp')
-rw-r--r-- | src/mongo/db/commands.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index 52c42917a8c..243176c316c 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -184,11 +184,19 @@ namespace mongo { bool have_ok = tmp.hasField("ok");
bool have_errmsg = tmp.hasField("errmsg");
+ std::string lastErrorMsg = errmsg;
+ if (have_errmsg) {
+ lastErrorMsg = tmp["errmsg"].String();
+ }
+
if (!have_ok)
result.append( "ok" , ok ? 1.0 : 0.0 );
- if ( !ok && !have_errmsg) {
- result.append("errmsg", errmsg);
+ if (!ok) {
+ if (!have_errmsg) {
+ result.append("errmsg", errmsg);
+ }
+ setLastError(0, lastErrorMsg.c_str());
}
}
|