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

Implement CRUD spec exception hierarchy

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.0
    • None
    • None

    Description

      The CRUD API requires two exception types for write operations like insert_one, update_one, update_many, delete_one, and delete_many - WriteError and WriteConcernError. We can accomplish this in PyMongo without breaking existing APIs and apps by tweaking the inheritance hierarchy:

      • WriteError and WriteConcernError will be introduced, inheriting from OperationFailure.
      • DuplicateKeyError will inherit from WriteError instead of directly from OperationFailure. WTimeoutError will inherit from WriteConcernError instead of directly from OperationFailure.
      • Other write errors will be raised as WriteError. Other write concern errors will be raise as WriteConcernError. (Assuming they can be differentiated from server results.)

      Applications can choose the level of granularity they want to use when catching these exceptions. Some applications may want to deal with DuplicateKeyError differently from generic WriteError. Some applications may want to deal with WTimeoutError differently from generic WriteConcernError.

      Attachments

        Activity

          People

            bernie@mongodb.com Bernie Hackett
            bernie@mongodb.com Bernie Hackett
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: