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

Implement CRUD spec exception hierarchy

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      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.

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

              Created:
              Updated:
              Resolved: