You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/crud/operation-error-handling.txt
+30-29Lines changed: 30 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
.. _java-operation-errors:
2
2
3
-
==============================
4
-
Write Operation Error Handling
5
-
==============================
3
+
=============================
4
+
Troubleshooting Write Errors
5
+
=============================
6
6
7
7
.. meta::
8
8
:description: Understand how to handle operation errors in the MongoDB Java Sync Driver, including error types like WriteErrror and ConnectionPoolCleared.
@@ -54,12 +54,11 @@ The `BulkWriteError <{+core-api+}/bulk/BulkWriteError.html>`__ type extends
54
54
operations and includes an ``index`` field that identifies the item in the bulk
55
55
operation that caused the error.
56
56
57
-
The `WriteConcernError <{+core-api+}/bulk/WriteConcernError.html>`__ is not
58
-
related to the ``WriteError`` type and details errors relating to the :ref:`write
59
-
concern </reference/write-concern/>`. In addition to the ``getCode``, ``getMessage``, and ``getDetails``
60
-
methods, ``WriteConcernError`` has the ``getCodeName`` method, which returns the
61
-
name associated with the error code. This type does not have the ``getCategory``
62
-
method.
57
+
The `WriteConcernError <{+core-api+}/bulk/WriteConcernError.html>`__ details
58
+
errors related to the :manual:`write concern </reference/write-concern/>`. It
59
+
does not extend the ``WriteError`` type, but has the same methods, except for
60
+
`getCategory`. In addition, ``WriteConcernError`` has the ``getCodeName``
61
+
method, which returns the name associated with the error code.
63
62
64
63
.. _java_error_write_errors:
65
64
@@ -70,42 +69,44 @@ The driver raises a ``WriteError`` error for any errors that it
70
69
encounters when performing single write operations that are not related to
71
70
satisfying the write concern.
72
71
73
-
For example, the driver raises a ``WriteError`` error if you attempt to insert a
74
-
document into a collection with an ObjectId value that already exists in the
75
-
collection. Suppose the collection has an existing document with an ``ObjectId`` of `1`. If you attempt to insert another document
76
-
where the value of ``ObjectId`` is ``1``, the driver prints the following
77
-
error message:
72
+
For example, the driver raises a ``WriteError`` error if you attempt to
73
+
insert a document into a collection that violates the collection's
74
+
schema validation rules. Suppose the collection has a rule where the
75
+
value of the ``quantity`` field must be an ``int`` type. If you
76
+
attempt to insert a document where the value of ``quantity`` is
77
+
``"three"``, the driver prints the following error message:
0 commit comments