-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: libmongoc
-
None
According to this comment on CDRIVER-2635, the codeName for a given error should be available via the reply parameter of whatever functions that have it. However, write functions that fail do not report any error information in the reply.
e.g. the following code sample
mongoc_write_concern_set_w(wc, 100); mongoc_write_concern_append(wc, options); if (!mongoc_collection_insert_one(collection, insert, options, &reply, &error)) { printf("err inserting, reply: %s\n", bson_as_relaxed_extended_json(&reply, NULL)); printf("err domain: %d code: %d message: %s\n", error.domain, error.code, error.message); }
Fails and produces the following output:
err inserting, reply: { "insertedCount" : 0 } err domain: 17 code: 2 message: cannot use 'w' > 1 when a host is not replicated
For reference, the shell does accurately report a "BadValue" codeName:
> db.mycoll.insertOne({}, {writeConcern: {w: 100}}) 2019-05-24T15:55:21.234-0400 E QUERY [js] WriteCommandError: cannot use 'w' > 1 when a host is not replicated : WriteCommandError({ "ok" : 0, "errmsg" : "cannot use 'w' > 1 when a host is not replicated", "code" : 2, "codeName" : "BadValue" })
- is depended on by
-
PHPC-1386 BulkWriteException and ExecutionTimeoutException do not expose codeName for server errors
- Blocked
-
DRIVERS-478 Errors raised by drivers should include codeName string from server response
- Implementing
- is related to
-
CDRIVER-2635 Errors raised by drivers should include codeName string from server response
- Closed
-
CDRIVER-4425 Provide access to raw result document when the server returns an error for a command
- Closed
-
DRIVERS-478 Errors raised by drivers should include codeName string from server response
- Implementing
-
CDRIVER-3422 Unified test format
- Closed