Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2509

Expose server error code name in OperationFailure exception message

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.15.0.alpha
    • Affects Version/s: None
    • Component/s: None
    • None
    • Minor Change

      Currently the driver exposes the code name in an attribute of Mongo::Error::OperationFailure, but not in the exception message itself. It would be helpful for diagnostics if the code name was included in the exception message.

      Since the message is being changed, I also suggest making it more clear that the error code (in parentheses) comes from the server. Especially for low numbered error codes (1-2 digits), to me, it is frequently not clear that the error code is server-generated.

      Looking at the relevant code it seems there is quite a bit of logic to extract error messages from what I assume are ancient server responses of server versions that the driver no longer supports (pre-2.6). The parsing that predates 2.6, if identified, can be removed.

      The following errors contain messages that are affected:

      OperationFailure (add code name, change formatting)
      BulkWriteError (code name not provided by server, change formatting to match OperationFailure)
      Auth errors (code name already exposed, change formatting to match OperationFailure)

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: