-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
Affects Version/s: 1.17.0-beta
-
Component/s: None
-
None
The following is a list of current error domains libmongoc can return:
MONGOC_ERROR_CLIENT, 1 MONGOC_ERROR_STREAM, 2 MONGOC_ERROR_PROTOCOL, 3 MONGOC_ERROR_CURSOR, 4 MONGOC_ERROR_QUERY, 5 MONGOC_ERROR_INSERT, 6 MONGOC_ERROR_SASL, 7 MONGOC_ERROR_BSON, 8 MONGOC_ERROR_MATCHER, 9 MONGOC_ERROR_NAMESPACE, 10 MONGOC_ERROR_COMMAND, 11 MONGOC_ERROR_COLLECTION, 12 MONGOC_ERROR_GRIDFS, 13 MONGOC_ERROR_SCRAM, 14 MONGOC_ERROR_SERVER_SELECTION, 15 MONGOC_ERROR_WRITE_CONCERN, 16 MONGOC_ERROR_SERVER, 17 MONGOC_ERROR_TRANSACTION, 18 MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, 19 BSON_ERROR_JSON, 1 BSON_ERROR_READER, 2 BSON_ERROR_INVALID, 3
There are three overlapping domains:
BSON_ERROR_JSON = MONGOC_ERROR_CLIENT
BSON_ERROR_READER = MONGOC_ERROR_STREAM
BSON_ERROR_INVALID = MONGOC_ERROR_PROTOCOL
The following is a list of documented error codes. (This is not a list of all possible errors that could be returned, since server errors, or errors originating from libmongocrypt, have their own codes)
MONGOC_ERROR_STREAM_INVALID_TYPE, 1 MONGOC_ERROR_STREAM_INVALID_STATE, 2 MONGOC_ERROR_STREAM_NAME_RESOLUTION, 3 MONGOC_ERROR_STREAM_SOCKET, 4 MONGOC_ERROR_STREAM_CONNECT, 5 MONGOC_ERROR_STREAM_NOT_ESTABLISHED, 6 MONGOC_ERROR_CLIENT_NOT_READY, 7 MONGOC_ERROR_CLIENT_TOO_BIG, 8 MONGOC_ERROR_CLIENT_TOO_SMALL, 9 MONGOC_ERROR_CLIENT_GETNONCE, 10 MONGOC_ERROR_CLIENT_AUTHENTICATE, 11 MONGOC_ERROR_CLIENT_NO_ACCEPTABLE_PEER, 12 MONGOC_ERROR_CLIENT_IN_EXHAUST, 13 MONGOC_ERROR_PROTOCOL_INVALID_REPLY, 14 MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, 15 MONGOC_ERROR_CURSOR_INVALID_CURSOR, 16 MONGOC_ERROR_QUERY_FAILURE, 17 MONGOC_ERROR_BSON_INVALID, 18 MONGOC_ERROR_MATCHER_INVALID, 19 MONGOC_ERROR_NAMESPACE_INVALID, 20 MONGOC_ERROR_NAMESPACE_INVALID_FILTER_TYPE, 21 MONGOC_ERROR_COMMAND_INVALID_ARG, 22 MONGOC_ERROR_COLLECTION_INSERT_FAILED, 23 MONGOC_ERROR_COLLECTION_UPDATE_FAILED, 24 MONGOC_ERROR_COLLECTION_DELETE_FAILED, 25 MONGOC_ERROR_COLLECTION_DOES_NOT_EXIST, 26 MONGOC_ERROR_GRIDFS_INVALID_FILENAME, 27 MONGOC_ERROR_SCRAM_NOT_DONE, 28 MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, 29 MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND, 59 MONGOC_ERROR_QUERY_NOT_TAILABLE, 13051 NGOC_ERROR_SERVER_SELECTION_BAD_WIRE_VERSION, 13052 MONGOC_ERROR_SERVER_SELECTION_FAILURE, 13053 MONGOC_ERROR_SERVER_SELECTION_INVALID_ID, 13054 MONGOC_ERROR_GRIDFS_CHUNK_MISSING, 13055 MONGOC_ERROR_GRIDFS_PROTOCOL_ERROR, 13056 MONGOC_ERROR_PROTOCOL_ERROR, 17 MONGOC_ERROR_WRITE_CONCERN_ERROR, 64 MONGOC_ERROR_DUPLICATE_KEY, 11000 MONGOC_ERROR_MAX_TIME_MS_EXPIRED, 50 MONGOC_ERROR_CHANGE_STREAM_NO_RESUME_TOKEN, 51 MONGOC_ERROR_CLIENT_SESSION_FAILURE, 52 MONGOC_ERROR_TRANSACTION_INVALID_STATE, 53 MONGOC_ERROR_GRIDFS_CORRUPT, 54 MONGOC_ERROR_GRIDFS_BUCKET_FILE_NOT_FOUND, 55 MONGOC_ERROR_GRIDFS_BUCKET_STREAM, 56 MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, 57 MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, 58 BSON_JSON_ERROR_READ_CORRUPT_JS, 1 BSON_JSON_ERROR_READ_INVALID_PARAM, 2 BSON_JSON_ERROR_READ_CB_FAILURE, 3 BSON_ERROR_READER_BADFD, 1 BSON_VALIDATE_NONE, 0 BSON_VALIDATE_UTF8, 1 BSON_VALIDATE_DOLLAR_KEYS, 2 BSON_VALIDATE_DOT_KEYS, 4 BSON_VALIDATE_UTF8_ALLOW_NULL, 8 BSON_VALIDATE_EMPTY_KEYS, 16
Some overlapping domains have overlapping codes.
For example, the domains BSON_ERROR_READER = MONGOC_ERROR_STREAM share the code BSON_ERROR_READER_BADFD = MONGOC_ERROR_STREAM_INVALID_TYPE.
I am not sure if there if there are functions that could return overlapping errors (assuming error API V2 is used), but this certainly makes error handling more difficult for users.