|
A user brought up that they get error message twice when using insertOne() or insertMany()
> db.grads_temp.insertOne({age:30, name: "Jina", major: "Math"})
|
WriteError({
|
"index": 0,
|
"code": 11000,
|
"errmsg": "E11000 duplicate key error collection: test.grads_temp index: name_1 dup key: { name: \"Jina\" }",
|
"op": {
|
"_id": ObjectId("5fc914698d565772d4400943"),
|
"age": 30,
|
"name": "Jina",
|
"major": "Math"
|
}
|
}) :
|
WriteError({
|
"index": 0,
|
"code": 11000,
|
"errmsg": "E11000 duplicate key error collection: test.grads_temp index: name_1 dup key: { name: \"Jina\" }",
|
"op": {
|
"_id": ObjectId("5fc914698d565772d4400943"),
|
"age": 30,
|
"name": "Jina",
|
"major": "Math"
|
}
|
})
|
WriteError@src/mongo/shell/bulk_api.js:465:48
|
mergeBatchResults@src/mongo/shell/bulk_api.js:871:49
|
executeBatch@src/mongo/shell/bulk_api.js:940:13
|
Bulk/this.execute@src/mongo/shell/bulk_api.js:1184:21
|
DBCollection.prototype.insertOne@src/mongo/shell/crud_api.js:264:9
|
@(shell):1:1
|
|
|
It certainly made all of our shell helpers that throw js exceptions on error a lot harder to read. For example, here is what you see when you screw up using the "count" helper:
> db.foo.count()
|
2016-05-23T15:29:52.327-0400 E QUERY [thread1] Error: count failed: { "ok" : 0, "errmsg" : "not master and slaveOk=false", "code" : 13435 } :
|
_getErrorWithCode@src/mongo/shell/utils.js:25:13
|
DBQuery.prototype.count@src/mongo/shell/query.js:387:11
|
DBCollection.prototype.count@src/mongo/shell/collection.js:1748:12
|
@(shell):1:1
|
Which is a lot more verbose than in previous versions and doesn't help contribute to a polished look for the product, especially for beginning users. Perhaps we should go through and remove all the throwing from our built-in js helpers? That would also achieve the same goal. I do agree that it's useful to see the callstack interactively, sometimes.
|