Skip to content

Commit 8341e97

Browse files
committed
DOCSP-30350 Updating grammar and Write/bulk Write error messages
1 parent e657ce8 commit 8341e97

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

source/crud/operation-error-handling.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ appropriate actions to either handle them or correct the error-causing code.
3737
Write Error Types
3838
-----------------
3939

40-
If the driver encounters an error while performing an write operation, it
40+
If the driver encounters an error while performing a write operation, it
4141
returns an error of the `WriteError <{+core-api+}/WriteError.html>`__ type.
4242

4343
The ``WriteError`` type contains the following methods:
@@ -61,6 +61,8 @@ methods, ``WriteConcernError`` has the ``getCodeName`` method, which returns the
6161
name associated with the error code. This type does not have the ``getCategory``
6262
method.
6363

64+
.. _java_error_write_errors:
65+
6466
Write Error
6567
~~~~~~~~~~~
6668

@@ -70,15 +72,15 @@ satisfying the write concern.
7072

7173
For example, the driver raises a ``WriteError`` error if you attempt to insert a
7274
document into a collection with an ObjectId value that already exists in the
73-
collection. Suppose the collection has an existing document with an ``ObjectId`` of `1`. If you attempt to insert a document
75+
collection. Suppose the collection has an existing document with an ``ObjectId`` of `1`. If you attempt to insert another document
7476
where the value of ``ObjectId`` is ``1``, the driver prints the following
7577
error message:
7678

7779
.. code-block:: none
7880
:copyable: false
7981

8082
WriteError: { code: 11000, message: "E11000 duplicate key error collection:
81-
testDB.testCollection index: _id_ dup key: { _id: 1 }", details: {} }
83+
testDB.testCollection index: _id_ dup key: { _id: 1 }", details: Document{{}}} }
8284

8385
In the preceding error message, the ``message`` field describes the reason for
8486
the error, and the ``details`` field provides specific details about the failing
@@ -88,17 +90,18 @@ operation. To address this error, you must revise the document to have a unique
8890
Bulk Write Error
8991
----------------
9092

91-
If this same example was run in during bulk write operation, an additional field
92-
would be added to the error detailing the index of the item with the duplicate
93-
``ObjectId``
93+
If the same example were run as a bulk write operation, the `index` field
94+
containing the index of the item with the duplicate ``ObjectId`` would be added
95+
to the message. For example, if the index of the item that produced the error is
96+
`2`, the driver would print the following error message:
9497

9598
.. code-block:: none
9699
:copyable: false
97100
:emphasize-lines: 1
98101

99-
BulkWriteError{index=2, code=11000, message='E11000 duplicate key error
102+
BulkWriteError{ index: 2, code: 11000, message: 'E11000 duplicate key error
100103
collection: testDB.testCollection index: _id_ dup key: { _id: 1 }',
101-
details=Document{{}}}
104+
details: Document{{}} }
102105

103106
Write Concern Error
104107
~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)