@@ -388,12 +388,6 @@ The preceding code examples produce the following output:
388388
389389 BulkWriteResult({'writeErrors': [], 'writeConcernErrors': [], 'nInserted': 2, 'nUpserted': 0, 'nMatched': 2, 'nModified': 2, 'nRemoved': 1, 'upserted': []}, acknowledged=True)
390390
391- .. tip::
392-
393- If any of the write operations fail, the {+driver-short+} raises a
394- ``BulkWriteException`` and does not perform any further operations. You can examine
395- the properties of the exception to determine which operation failed.
396-
397391Customize Bulk Write Operations
398392-------------------------------
399393
@@ -490,7 +484,9 @@ object that contains the following properties:
490484 - Description
491485
492486 * - ``Acknowledged``
493- - | Indicates whether the server acknowledged the bulk write operation.
487+ - | Indicates whether the server acknowledged the bulk write operation. If the
488+ value of this property is ``false`` and you try to access any other property
489+ of the ``ClientBulkWriteResult`` object, the driver throws an exception.
494490
495491 * - ``DeleteResults``
496492 - | An ``IReadOnlyDictionary<int, BulkWriteDeleteResult>`` object containing the
@@ -519,6 +515,45 @@ object that contains the following properties:
519515 * - ``UpsertedCount``
520516 - | The number of documents upserted, if any.
521517
518+ Handling Exceptions
519+ -------------------
520+
521+ If any of the operations in a bulk write operation fail, the {+driver-short+} throws a
522+ ``ClientBulkWriteException`` and does not perform any further operations.
523+
524+ A ``ClientBulkWriteException`` object contains the following properties:
525+
526+ .. list-table::
527+ :header-rows: 1
528+ :stub-columns: 1
529+
530+ * - Property
531+ - Description
532+ * - ``connectionId``
533+ - | The connection identifier.
534+ |
535+ | **Data Type:** `ConnectionId <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Core.Connections.ConnectionId.html>`__
536+ * - ``message``
537+ - | The error message.
538+ |
539+ | **Data Type:** {+string-data-type+}
540+ * - ``writeErrors``
541+ - | A dictionary of errors that occurred during the bulk write operation.
542+ |
543+ | **Data Type:** IReadOnlyDictionary<int, `WriteError <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.WriteError.html>`__>
544+ * - ``partialResult``
545+ - | The results of any successful operations performed before the exception was thrown.
546+ |
547+ | **Data Type:** `ClientBulkWriteResult <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.ClientBulkWriteResult.html>`__
548+ * - ``writeConcernErrors``
549+ - | Write concern errors that occurred during execution of the bulk write operation.
550+ |
551+ | **Data Type:** IReadOnlyList<`MongoWriteConcernException <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.MongoWriteConcernException.html>`__>
552+ * - ``innerException``
553+ - | The inner exception.
554+ |
555+ | **Data Type:** `Exception <https://learn.microsoft.com/dotnet/api/system.exception>`__
556+
522557Additional Information
523558----------------------
524559
@@ -544,3 +579,4 @@ guide, see the following API documentation:
544579- `BulkWriteInsertOneResult <{+new-api-root+}/MongoDB.Driver/MongoClient.BulkWriteInsertOneResult.html>`__
545580- `BulkWriteUpdateResult <{+new-api-root+}/MongoDB.Driver/MongoClient.BulkWriteUpdateResult.html>`__
546581- `BulkWriteDeleteResult <{+new-api-root+}/MongoDB.Driver/MongoClient.BulkWriteDeleteResult.html>`__
582+ - `ClientBulkWriteException <{+new-api-root+}/MongoDB.Driver/MongoClient.ClientBulkWriteException.html>`__
0 commit comments