mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
good error msg on an assertion failure in dbCommand
This commit is contained in:
parent
50f7e4dc7a
commit
a8339eedf6
21
db/query.cpp
21
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user