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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.11
    • None

    Description

      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, ....}
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: