In pymongo, when a DuplicateKeyError caught, what\'s the proper way to find out the duplicate value behind the the exception?
DuplicateKeyError
Currently I do this
In dev version of pymongo (2.7) you can check with error_document property:
pymongo
error_document
try: db.coll.insert({name: 'some_value'}) except pymongo.errors.DuplicateKeyError, e: print e.error_document
As far as I know, in 2.6 and earlier versions, all info except error msg and code is discarded.
msg
code