Details
-
Improvement
-
Status: Closed
-
Minor - P4
-
Resolution: Duplicate
-
None
-
None
-
Minor Change
Description
Currently we throw with strings in js code (collection/db/query/mongo/etc) when we have an object/bsonobj. We should simply build a wrapper object and throw that.
$ grep -i throw.*tojson\( src/mongo/shell/*.js |
src/mongo/shell/collection.js: throw "error " + tojson( ret ); |
src/mongo/shell/collection.js: throw "error dropping indexes : " + tojson( res ); |
src/mongo/shell/collection.js: throw "drop failed: " + tojson( ret ); |
src/mongo/shell/collection.js: throw "findAndModifyFailed failed: " + tojson( ret ); |
src/mongo/shell/collection.js: throw "distinct failed: " + tojson( res ); |
src/mongo/shell/collection.js: throw "distinct failed: " + tojson( res ); |
src/mongo/shell/collection.js: throw "aggregate failed: " + tojson(res); |
src/mongo/shell/collection.js: throw "map reduce failed:" + tojson(raw); |
src/mongo/shell/db.js: throw "Could not insert into system.users: " + tojson(e); |
src/mongo/shell/db.js: throw "profile command failed: " + tojson( res ); |
src/mongo/shell/db.js: throw tojson( res ); |
src/mongo/shell/db.js: throw "group command failed: " + tojson( ret ); |
src/mongo/shell/db.js: throw "getlasterror failed: " + tojson( res ); |
src/mongo/shell/db.js: throw "getlasterror failed: " + tojson( res ); |
src/mongo/shell/mongo.js: throw "listDatabases failed:" + tojson( res ); |
src/mongo/shell/query.js: throw "error: " + tojson( ret ); |
src/mongo/shell/query.js: throw "error: " + tojson( ret ); |
src/mongo/shell/query.js: throw "count failed: " + tojson( res ); |
src/mongo/shell/query.js: throw "error: " + tojson( ret ); |
src/mongo/shell/shardingtest.js: throw "command " + tojson( cmd ) + " failed: " + tojson( res ); |
In addition to these we should fix all "throw <string>" instances to throw "Error(<string>)".
Attachments
Issue Links
- duplicates
-
SERVER-10177 Javascript code should throw instances of Error instead of strings.
-
- Closed
-