diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/db.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/shell/db.js b/shell/db.js index eef7d8dcef0..829969540f2 100644 --- a/shell/db.js +++ b/shell/db.js @@ -478,6 +478,12 @@ DB.prototype.forceError = function(){ } DB.prototype.getLastError = function( w , wtimeout ){ + var res = this.getLastErrorObj( w , wtimeout ); + if ( ! res.ok ) + throw "getlasterror failed: " + tojson( res ); + return res.err; +} +DB.prototype.getLastErrorObj = function( w , wtimeout ){ var cmd = { getlasterror : 1 }; if ( w ){ cmd.w = w; @@ -485,12 +491,7 @@ DB.prototype.getLastError = function( w , wtimeout ){ cmd.wtimeout = wtimeout; } var res = this.runCommand( cmd ); - if ( ! res.ok ) - throw "getlasterror failed: " + tojson( res ); - return res.err; -} -DB.prototype.getLastErrorObj = function(){ - var res = this.runCommand( { getlasterror : 1 } ); + if ( ! res.ok ) throw "getlasterror failed: " + tojson( res ); return res; |