The mongoc_error_code_t enum does not agree with the server's error codes. For example, recent servers return error code 13 if a command is unauthorized, but 13 means MONGOC_ERROR_CLIENT_IN_EXHAUST in the enum. MONGOC_ERROR_CLIENT_AUTHENTICATE, on the other hand, is 11 in the enum. Nevertheless, when a command fails on the server the driver sets the bson_error_t's code to the server error code, as if the enum values and the server's values were related. Applications comparing a bson_error_t's "code" field to the enum values are often misinformed about the cause of the error.
The enum and bson_error_t can't work as designed – the client and server can't share that list of codes, because they don't agree now and can't be made to agree in the future. I need to investigate if there is a simple upgrade path, or if I just need to document the problem now and wait for version 2.0 for a true fix.
- is depended on by
-
CDRIVER-709 Define mongoc_error_code_t value for "duplicate key error"
- Closed
- is related to
-
CXX-834 Return local mongoc errors and server errors in different error spaces
- Backlog
- related to
-
CDRIVER-662 Inconsistent errs from CRUD functions
- Closed
-
CXX-808 Missing error codes for server-side errors
- Closed
-
PHPC-292 Running a command against a server that no connection can be made against, shows weird exception message
- Closed
-
CDRIVER-728 Error code for connection timeouts
- Closed
-
CDRIVER-1172 Change default error API version to 2
- Backlog
-
CDRIVER-449 Could not find useful documentation on bson_error_t
- Closed
-
CDRIVER-1434 Show set_error_api in examples
- Closed