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

Do not use BulkWriteException for client-side errors

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 2.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Original title: BulkWriteException's proxy behavior may violate contract for ServerException

      ServerException's documentation states:

      Base class for exceptions thrown by the server. The code of this exception and its subclasses will correspond to the original error code from the server.

      BulkWriteException extends ServerException through WriteException; however, not all BulkWriteExceptions are derived from server-side errors. Logic in phongo_execute_bulk_write ensures that a BulkWriteException is always thrown once mongoc_bulk_operation_execute() has been called to ensure that an intermediary write result is always accessible (see: PHPC-1373). If an error from mongoc_bulk_operation_execute happens to yield different exception, it will be thrown first and become accessible via BulkWriteException::getPrevious().

      This behavior is unintuitive and complicates logic in PHPLIB's test suite that checks whether an exception is a client-side error (since we must unwrap a BulkWriteException to determine the original exception).

            Assignee:
            Unassigned Unassigned
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: