Rename MongoEngineConnectionError to ConnectionFailure #2111
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I originally changed the exception name from
ConnectionErrortoMongoEngineConnectionErrorinb02904e, inspired by landscape.io's package health report, which argued that
ConnectionErroris already a built-in exception in Python 3.I do agree that we shouldn't override built-in exceptions. [0] That said, it’s silly to add a "MongoEngine" prefix to any class within the
mongoenginemodule (and especially to just one exception class out of many). I've decided to do what PyMongo does and call this exceptionConnectionFailure.Note that this is a breaking change and people will need to rename
MongoEngineConnectionErrors in their code toConnectionFailure. Moreover, if they use PyMongo'sConnectionFailurefor anything, they'll need to take extra care to avoid conflicts, e.g. by using:[0] Note that some popular packages still overwrite
ConnectionError, e.g.https://github.com/kennethreitz/requests/blob/4983a9bde39c6320aa4f3e34e50dac6e263dab6f/requests/exceptions.py#L32
or
https://github.com/andymccurdy/redis-py/blob/0be4d2920684345eb52115c7142c39d65356e7d4/redis/exceptions.py#L8