Error handling in drivers currently relies on message substring checks for "not master" and "node is recovering". It is used to help determine whether an error is a server state change error per SDAM, or if it is a retryable read / write error. We intend to remove those checks in DRIVERS-1152, but we are unable to test it with our existing SDAM integration test runner. The test runner uses the failCommand failpoint to simulate errors. But failCommand responses have a fixed errmsg: "Failing command due to 'failCommand' failpoint", so we cannot check the substring matching behavior.
If possible, could the failCommand arguments have an additional errorMessage field to overwrite or append to the returned errmsg? Here is an example API proposal:
Secondly, drivers error handling checks for the presence of an error code. Older MongoDB servers may not return an error code in all cases. Would it be possible to make errorCode optional so we can test the omission of an error code?