File: errors.rst

package info (click to toggle)
mongo-c-driver 1.17.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 37,256 kB
  • sloc: ansic: 152,613; javascript: 7,954; python: 3,259; sh: 138; makefile: 29; xml: 10
file content (180 lines) | stat: -rw-r--r-- 49,593 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
:man_page: mongoc_errors

« :doc:`index`

Error Reporting
===============

Description
-----------

Many C Driver functions report errors by returning ``false`` or -1 and filling out a :symbol:`bson:bson_error_t` structure with an error domain, error code, and message. Use ``domain`` to determine which subsystem generated the error, and ``code`` for the specific error. ``message`` is a human-readable error description.

See also: :doc:`Handling Errors in libbson <bson:errors>`.

+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|Domain                                   | Code                                                                                                                            | Description                                                                                                                                                                                                                                                                                                                                |
+=========================================+=================================================================================================================================+============================================================================================================================================================================================================================================================================================================================================+
| ``MONGOC_ERROR_CLIENT``                 | ``MONGOC_ERROR_CLIENT_TOO_BIG``                                                                                                 | You tried to send a message larger than the server's max message size.                                                                                                                                                                                                                                                                     |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_CLIENT_AUTHENTICATE``                                                                                            | Wrong credentials, or failure sending or receiving authentication messages.                                                                                                                                                                                                                                                                |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_CLIENT_NO_ACCEPTABLE_PEER``                                                                                      | You tried an TLS connection but the driver was not built with TLS.                                                                                                                                                                                                                                                                         |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_CLIENT_IN_EXHAUST``                                                                                              | You began iterating an exhaust cursor, then tried to begin another operation with the same :symbol:`mongoc_client_t`.                                                                                                                                                                                                                      |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_CLIENT_SESSION_FAILURE``                                                                                         | Failure related to creating or using a logical session.                                                                                                                                                                                                                                                                                    |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG``                                                                                  | Failure related to arguments passed when initializing Client-Side Field Level Encryption.                                                                                                                                                                                                                                                  |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE``                                                                                | Failure related to Client-Side Field Level Encryption.                                                                                                                                                                                                                                                                                     |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_STREAM``                 | ``MONGOC_ERROR_STREAM_NAME_RESOLUTION``                                                                                         | DNS failure.                                                                                                                                                                                                                                                                                                                               |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_STREAM_SOCKET``                                                                                                  | Timeout communicating with server, or connection closed.                                                                                                                                                                                                                                                                                   |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_STREAM_CONNECT``                                                                                                 | Failed to connect to server.                                                                                                                                                                                                                                                                                                               |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_PROTOCOL``               | ``MONGOC_ERROR_PROTOCOL_INVALID_REPLY``                                                                                         | Corrupt response from server.                                                                                                                                                                                                                                                                                                              |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION``                                                                                      | The server version is too old or too new to communicate with the driver.                                                                                                                                                                                                                                                                   |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_CURSOR``                 | ``MONGOC_ERROR_CURSOR_INVALID_CURSOR``                                                                                          | You passed bad arguments to :symbol:`mongoc_collection_find_with_opts`, or you called :symbol:`mongoc_cursor_next` on a completed or failed cursor, or the cursor timed out on the server.                                                                                                                                                 |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_CHANGE_STREAM_NO_RESUME_TOKEN``                                                                                  | A resume token was not returned in a document found with :symbol:`mongoc_change_stream_next`                                                                                                                                                                                                                                               |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_QUERY``                  | ``MONGOC_ERROR_QUERY_FAILURE``                                                                                                  | :ref:`Error API Version 1 <error_api_version>`: Server error from command or query. The server error message is in ``message``.                                                                                                                                                                                                            |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_SERVER``                 | ``MONGOC_ERROR_QUERY_FAILURE``                                                                                                  | :ref:`Error API Version 2 <error_api_version>`: Server error from command or query. The server error message is in ``message``.                                                                                                                                                                                                            |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_SASL``                   | A SASL error code.                                                                                                              | ``man sasl_errors`` for a list of codes.                                                                                                                                                                                                                                                                                                   |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_BSON``                   | ``MONGOC_ERROR_BSON_INVALID``                                                                                                   | You passed an invalid or oversized BSON document as a parameter, or called :symbol:`mongoc_collection_create_index` with invalid keys, or the server reply was corrupt.                                                                                                                                                                    |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_NAMESPACE``              | ``MONGOC_ERROR_NAMESPACE_INVALID``                                                                                              | You tried to create a collection with an invalid name.                                                                                                                                                                                                                                                                                     |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_COMMAND``                | ``MONGOC_ERROR_COMMAND_INVALID_ARG``                                                                                            | Many functions set this error code when passed bad parameters. Print the error message for details.                                                                                                                                                                                                                                        |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION``                                                                                      | You tried to use a command option the server does not support.                                                                                                                                                                                                                                                                             |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_DUPLICATE_KEY``                                                                                                  | An insert or update failed because because of a duplicate ``_id`` or other unique-index violation.                                                                                                                                                                                                                                         |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_MAX_TIME_MS_EXPIRED``                                                                                            | The operation failed because maxTimeMS expired.                                                                                                                                                                                                                                                                                            |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_SERVER_SELECTION_INVALID_ID``                                                                                    | The ``serverId`` option for an operation conflicts with the pinned server for that operation's client session (denoted by the ``sessionId`` option).                                                                                                                                                                                       |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_COMMAND``                | `Error code from server <https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err>`_.                        | :ref:`Error API Version 1 <error_api_version>`: Server error from a command. The server error message is in ``message``.                                                                                                                                                                                                                   |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_SERVER``                 | `Error code from server <https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err>`_.                        | :ref:`Error API Version 2 <error_api_version>`: Server error from a command. The server error message is in ``message``.                                                                                                                                                                                                                   |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_COLLECTION``             | ``MONGOC_ERROR_COLLECTION_INSERT_FAILED``, ``MONGOC_ERROR_COLLECTION_UPDATE_FAILED``, ``MONGOC_ERROR_COLLECTION_DELETE_FAILED``.| Invalid or empty input to :symbol:`mongoc_collection_insert_one`, :symbol:`mongoc_collection_insert_bulk`, :symbol:`mongoc_collection_update_one`, :symbol:`mongoc_collection_update_many`, :symbol:`mongoc_collection_replace_one`, :symbol:`mongoc_collection_delete_one`, or :symbol:`mongoc_collection_delete_many`.                   |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_COLLECTION``             | `Error code from server <https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err>`_.                        | :ref:`Error API Version 1 <error_api_version>`: Server error from :symbol:`mongoc_collection_insert_one`, :symbol:`mongoc_collection_insert_bulk`, :symbol:`mongoc_collection_update_one`, :symbol:`mongoc_collection_update_many`, :symbol:`mongoc_collection_replace_one`,                                                               |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_SERVER``                 | `Error code from server <https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err>`_.                        | :ref:`Error API Version 2 <error_api_version>`: Server error from :symbol:`mongoc_collection_insert_one`, :symbol:`mongoc_collection_insert_bulk`, :symbol:`mongoc_collection_update_one`, :symbol:`mongoc_collection_update_many`, :symbol:`mongoc_collection_replace_one`,                                                               |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_GRIDFS``                 | ``MONGOC_ERROR_GRIDFS_CHUNK_MISSING``                                                                                           | The GridFS file is missing a document in its ``chunks`` collection.                                                                                                                                                                                                                                                                        |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_GRIDFS_CORRUPT``                                                                                                 | A data inconsistency was detected in GridFS.                                                                                                                                                                                                                                                                                               |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_GRIDFS_INVALID_FILENAME``                                                                                        | You passed a NULL filename to :symbol:`mongoc_gridfs_remove_by_filename`.                                                                                                                                                                                                                                                                  |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_GRIDFS_PROTOCOL_ERROR``                                                                                          | You called :symbol:`mongoc_gridfs_file_set_id` after :symbol:`mongoc_gridfs_file_save`, or tried to write on a closed GridFS stream.                                                                                                                                                                                                       |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_GRIDFS_BUCKET_FILE_NOT_FOUND``                                                                                   | A GridFS file is missing from ``files`` collection.                                                                                                                                                                                                                                                                                        |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                         | ``MONGOC_ERROR_GRIDFS_BUCKET_STREAM``                                                                                           | An error occurred on a stream created from a GridFS operation like :symbol:`mongoc_gridfs_bucket_upload_from_stream`.                                                                                                                                                                                                                      |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_SCRAM``                  | ``MONGOC_ERROR_SCRAM_PROTOCOL_ERROR``                                                                                           | Failure in SCRAM-SHA-1 authentication.                                                                                                                                                                                                                                                                                                     |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_SERVER_SELECTION``       | ``MONGOC_ERROR_SERVER_SELECTION_FAILURE``                                                                                       | No replica set member or mongos is available, or none matches your :doc:`read preference <mongoc_read_prefs_t>`, or you supplied an invalid :symbol:`mongoc_read_prefs_t`.                                                                                                                                                                 |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_WRITE_CONCERN``          | `Error code from server <https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err>`_.                        | There was a :doc:`write concern <mongoc_write_concern_t>` error or :doc:`timeout <mongoc_write_concern_set_wtimeout>` from the server.                                                                                                                                                                                                     |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_TRANSACTION``            | ``MONGOC_ERROR_TRANSACTION_INVALID``                                                                                            | You attempted to start a transaction when one is already in progress, or commit or abort when there is no transaction.                                                                                                                                                                                                                     |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION`` | Error code produced by libmongocrypt.                                                                                           | An error occurred in the library responsible for Client Side Encryption                                                                                                                                                                                                                                                                    |
+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

.. _error_labels:

Error Labels
------------

In some cases your application must make decisions based on what category of error the driver has returned, but these categories do not correspond perfectly to an error domain or code. In such cases, error *labels* provide a reliable way to determine how your application should respond to an error.

Any C Driver function that has a :symbol:`bson:bson_t` out-parameter named ``reply`` may include error labels to the reply, in the form of a BSON field named "errorLabels" containing an array of strings:

.. code-block:: none

  { "errorLabels": [ "TransientTransactionError" ] }

Use :symbol:`mongoc_error_has_label` to test if a reply contains a specific label. See :symbol:`mongoc_client_session_start_transaction` for example code that demonstrates the use of error labels in application logic.

The following error labels are currently defined. Future versions of MongoDB may introduce new labels.

TransientTransactionError
^^^^^^^^^^^^^^^^^^^^^^^^^

Within a multi-document transaction, certain errors can leave the transaction in an unknown or aborted state. These include write conflicts, primary stepdowns, and network errors. In response, the application should abort the transaction and try the same sequence of operations again in a new transaction.

UnknownTransactionCommitResult
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

When :symbol:`mongoc_client_session_commit_transaction` encounters a network error or certain server errors, it is not known whether the transaction was committed. Applications should attempt to commit the transaction again until: the commit succeeds, the commit fails with an error *not* labeled "UnknownTransactionCommitResult", or the application chooses to give up.

.. _errors_error_api_version:
.. _error_api_version:

Setting the Error API Version
-----------------------------

The driver's error reporting began with a design flaw: when the error *domain* is ``MONGOC_ERROR_COLLECTION``, ``MONGOC_ERROR_QUERY``, or ``MONGOC_ERROR_COMMAND``, the error *code* might originate from the server or the driver. An application cannot always know where an error originated, and therefore cannot tell what the code means.

For example, if :symbol:`mongoc_collection_update_one` sets the error's domain to ``MONGOC_ERROR_COLLECTION`` and its code to 24, the application cannot know whether 24 is the generic driver error code ``MONGOC_ERROR_COLLECTION_UPDATE_FAILED`` or the specific server error code "LockTimeout".

To fix this flaw while preserving backward compatibility, the C Driver 1.4 introduces "Error API Versions". Version 1, the default Error API Version, maintains the flawed behavior. Version 2 adds a new error domain, ``MONGOC_ERROR_SERVER``. In Version 2, error codes originating on the server always have error domain ``MONGOC_ERROR_SERVER`` or ``MONGOC_ERROR_WRITE_CONCERN``. When the driver uses Version 2 the application can always determine the origin and meaning of error codes. New applications should use Version 2, and existing applications should be updated to use Version 2 as well.

+------------------------------------------------------+----------------------------------------+----------------------------------------+
| Error Source                                         | API Version 1                          |  API Version 2                         |
+------------------------------------------------------+----------------------------------------+----------------------------------------+
| :symbol:`mongoc_cursor_error`                        | ``MONGOC_ERROR_QUERY``                 | ``MONGOC_ERROR_SERVER``                |
+------------------------------------------------------+----------------------------------------+----------------------------------------+
| :symbol:`mongoc_client_command_with_opts`,           | ``MONGOC_ERROR_QUERY``                 | ``MONGOC_ERROR_SERVER``                |
| :symbol:`mongoc_database_command_with_opts`, and     |                                        |                                        |
| other command functions                              |                                        |                                        |
+------------------------------------------------------+----------------------------------------+----------------------------------------+
| :symbol:`mongoc_collection_count_with_opts`          | ``MONGOC_ERROR_QUERY``                 | ``MONGOC_ERROR_SERVER``                |
| :symbol:`mongoc_client_get_database_names_with_opts`,|                                        |                                        |
| and other command helper functions                   |                                        |                                        |
+------------------------------------------------------+----------------------------------------+----------------------------------------+
| :symbol:`mongoc_collection_insert_one`               | ``MONGOC_ERROR_COMMAND``               | ``MONGOC_ERROR_SERVER``                |
| :symbol:`mongoc_collection_insert_bulk`              |                                        |                                        |
| :symbol:`mongoc_collection_update_one`               |                                        |                                        |
| :symbol:`mongoc_collection_update_many`              |                                        |                                        |
| :symbol:`mongoc_collection_replace_one`              |                                        |                                        |
| :symbol:`mongoc_collection_delete_one`               |                                        |                                        |
| :symbol:`mongoc_collection_delete_many`              |                                        |                                        |
+------------------------------------------------------+----------------------------------------+----------------------------------------+
| :symbol:`mongoc_bulk_operation_execute`              | ``MONGOC_ERROR_COMMAND``               | ``MONGOC_ERROR_SERVER``                |
+------------------------------------------------------+----------------------------------------+----------------------------------------+
| Write-concern timeout                                | ``MONGOC_ERROR_WRITE_CONCERN``         | ``MONGOC_ERROR_WRITE_CONCERN``         |
+------------------------------------------------------+----------------------------------------+----------------------------------------+

The Error API Versions are defined with ``MONGOC_ERROR_API_VERSION_LEGACY`` and ``MONGOC_ERROR_API_VERSION_2``. Set the version with :symbol:`mongoc_client_set_error_api` or :symbol:`mongoc_client_pool_set_error_api`.

See Also
--------

`MongoDB Server Error Codes <https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err>`_

.. only:: html

  Functions
  ---------

  .. toctree::
    :titlesonly:
    :maxdepth: 1

    mongoc_error_has_label