summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-04-28 15:19:53 -0400
committerDwight <dmerriman@gmail.com>2008-04-28 15:19:53 -0400
commita8339eedf68b1a7b483840c2c8236aea98970347 (patch)
tree4a6f5b6062166b93c211bce2b2b827c6c4702d98
parent50f7e4dc7a192e879e6d3cc9515428d3efb39aef (diff)
downloadmongo-a8339eedf68b1a7b483840c2c8236aea98970347.tar.gz
good error msg on an assertion failure in dbCommand
-rw-r--r--db/query.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/db/query.cpp b/db/query.cpp
index 6aeb680fdcf..45465da3675 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -448,14 +448,12 @@ bool dbEval(JSObj& cmd, JSObjBuilder& result) {
//
// returns true if ran a cmd
//
-inline bool runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuilder &b, JSObjBuilder& anObjBuilderForYa) {
+inline bool _runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuilder &b, JSObjBuilder& anObjBuilderForYa) {
const char *p = strchr(ns, '.');
if( !p ) return false;
if( strcmp(p, ".$cmd") != 0 ) return false;
-// ss << "\n $cmd: " << jsobj.toString();
-
bool ok = false;
bool valid = false;
@@ -464,8 +462,6 @@ inline bool runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuild
Element e;
e = jsobj.firstElement();
-// assert(false);
-
if( e.eoo() ) goto done;
if( e.type() == Code ) {
valid = true;
@@ -594,6 +590,21 @@ done:
return true;
}
+bool runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuilder &b, JSObjBuilder& anObjBuilderForYa) {
+ try {
+ return _runCommands(ns, jsobj, ss, b, anObjBuilderForYa);
+ }
+ catch( AssertionException ) {
+ ;
+ }
+ ss << " assertion ";
+ anObjBuilderForYa.append("errmsg", "db assertion failure");
+ anObjBuilderForYa.append("ok", 0.0);
+ JSObj x = anObjBuilderForYa.done();
+ b.append((void*) x.objdata(), x.objsize());
+ return true;
+}
+
int nCaught = 0;
void killCursors(int n, long long *ids) {