I got this mongo exception recently, and when i printed my error object it did not mention where in my code that exception was risen.
{ MongoError: E11000 duplicate key error collection: test.users index: email_1 dup key: { : "test@gmail.com" }
[0] at Function.create (C:\proj\node_modules\mongodb-core\lib\error.js:43:12)
[0] at toError (C:\proj\node_modules\mongodb\lib\utils.js:149:22)
[0] at coll.s.topology.insert (C:\proj\node_modules\mongodb\lib\operations\collection_ops.js:859:39)
[0] at handler (C:\proj\node_modules\mongodb-core\lib\topologies\replset.js:1155:22)
[0] at C:\proj\node_modules\mongodb-core\lib\connection\pool.js:397:18
[0] at process._tickCallback (internal/process/next_tick.js:61:11)
[0] driver: true,
[0] name: 'MongoError',
[0] index: 0,
[0] code: 11000,
[0] errmsg:
[0] 'E11000 duplicate key error collection: test.users index: email_1 dup key: { : "test@gmail.com" }',
[0] [Symbol(mongoErrorContextSymbol)]: {} }
As you can see, it only mentions in what files in the mongodb module it had risen, but now which lines in my own project code had started this entire chain of events. Perhaps it's some .save() function that I used? Why doesn't it show this line, and is it possible to see it anywhere? that would really help with my debugging efforts