diff options
| author | 2020-05-26 18:56:30 +0200 | |
|---|---|---|
| committer | 2020-05-26 19:07:14 +0200 | |
| commit | ec8205cfd7adb5e40aabd52e497e4e387b932211 (patch) | |
| tree | 63dfd330450cb0dc782f6af4106557e62a8d99ce | |
| parent | Improve some docstrings for RedisCache. (diff) | |
Swap the order for the validate_cache checks.
| -rw-r--r-- | bot/utils/redis_cache.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/bot/utils/redis_cache.py b/bot/utils/redis_cache.py index a1196fcb5..895a12da4 100644 --- a/bot/utils/redis_cache.py +++ b/bot/utils/redis_cache.py @@ -129,20 +129,20 @@ class RedisCache: async def _validate_cache(self) -> None: """Validate that the RedisCache is ready to be used.""" - if self.bot is None: + if self._namespace is None: error_message = ( - "Critical error: RedisCache has no `Bot` instance. " - "This happens when the class RedisCache was created in doesn't " - "have a Bot instance. Please make sure that you're instantiating " - "the RedisCache inside a class that has a Bot instance attribute." + "Critical error: RedisCache has no namespace. " + "This object must be initialized as a class attribute." ) log.error(error_message) raise RuntimeError(error_message) - if self._namespace is None: + if self.bot is None: error_message = ( - "Critical error: RedisCache has no namespace. " - "This object must be initialized as a class attribute." + "Critical error: RedisCache has no `Bot` instance. " + "This happens when the class RedisCache was created in doesn't " + "have a Bot instance. Please make sure that you're instantiating " + "the RedisCache inside a class that has a Bot instance attribute." ) log.error(error_message) raise RuntimeError(error_message) |