Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-163

Throw WriteException & BulkWriteException on write failure

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 0.1.5
    • Affects Version/s: 0.1.4
    • Component/s: None
    • None

      Currently it is fairly complicated to check if a write succeeded or not.
      We don't throw an exception on writeerror nor writeconcernerror - but we do on connection and other related errors.

      Furthermore, the user has to check both Result->getWriteErrors() and Result->getWriteConcernError() to see if there was an error.
      This doesn't make whole lot of sense :/

      We should throw MongoDB\Driver\BulkWriteException on bulkWrite failure, which contains ->getWriteResult() which returns the original WriteResult object.
      The WriteResult object then has ->getWriteErrors() and ->getWriteConcernError().

      For execute[Insert|Update|Delete]() we unwrap the BulkWriteException and throw DuplicateKeyException, WriteConcernException or generic WriteException on failure.

            Assignee:
            bjori Hannes Magnusson
            Reporter:
            bjori Hannes Magnusson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: