Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1787

PyMongo exceptions raised from server errors should include the errorCode in the traceback message

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.11
    • Affects Version/s: None
    • Component/s: None

      We should include more information from server command failures in our OperationFailure exception. This would help debug exceptions that are not caught, for example, when an operation inside a multi-document transaction fails with WriteConflict the stack trace is:

      ...
      File "/home/shane/git/mongo-python-driver/pymongo/helpers.py", line 155, in _check_command_response
      raise OperationFailure(msg % errmsg, code, response)
      pymongo.errors.OperationFailure: WriteConflict
      

      It would be better if we included more information, like the entire error document:

      ...
      raise OperationFailure(msg % errmsg, code, response)
      pymongo.errors.OperationFailure: WriteConflict , full error: {"ok": 0, "errmsg": "WriteConflict", "code": 112, ....}
      

            Assignee:
            julius.park@mongodb.com Julius Park (Inactive)
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: