twisted / txmongo

asynchronous python driver for mongo
https://txmongo.readthedocs.io
Apache License 2.0
338 stars 102 forks source link

Fix retrieving error messages #274

Closed Gowee closed 3 years ago

Gowee commented 3 years ago

Hi.

As is reported in #236, error messages in exceptions raised by txmongo are sometimes ambiguous.

The reason is that txmongo only picks the field err, which is not present all the time even if there are actual errors. I cannot find a detailed and exhaustive documentation for all possible fields (there are some related documentations, but for example, none of them formally documents the existence of the field codeName). But at least, there are codeName, and errmsg in recent MongoDB versions.

This PR is going to fix the problem by fall backing to codeName and errmsg when err is not present. It picks any of the three fields whichever is present.

It should partially fix #236, giving a detailed error message: TxMongo: AtlasError: no SNI name sent, make sure using a MongoDB 3.4+ driver/shell.

coveralls commented 3 years ago

Coverage Status

Coverage increased (+0.02%) to 93.017% when pulling d8b6cbed10a1a979b6165f9a76fb2e6dc6f71867 on Gowee:fixerrmsg into d0161a63e8eafe3eca18a0e2f7ceac6d368eea5e on twisted:master.

IlyaSkriblovsky commented 3 years ago

Thanks, this looks reasonable