mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-26 21:33:12 +00:00
Use raise from in plugins (#11095)
* Use raise from. * Add changelog fragment.
This commit is contained in:
8
plugins/cache/redis.py
vendored
8
plugins/cache/redis.py
vendored
@@ -147,8 +147,10 @@ class CacheModule(BaseCacheModule):
|
||||
"""
|
||||
try:
|
||||
from redis.sentinel import Sentinel
|
||||
except ImportError:
|
||||
raise AnsibleError("The 'redis' python module (version 2.9.0 or newer) is required to use redis sentinel.")
|
||||
except ImportError as e:
|
||||
raise AnsibleError(
|
||||
"The 'redis' python module (version 2.9.0 or newer) is required to use redis sentinel."
|
||||
) from e
|
||||
|
||||
if ";" not in uri:
|
||||
raise AnsibleError("_uri does not have sentinel syntax.")
|
||||
@@ -170,7 +172,7 @@ class CacheModule(BaseCacheModule):
|
||||
try:
|
||||
return scon.master_for(self._sentinel_service_name, socket_timeout=0.2)
|
||||
except Exception as exc:
|
||||
raise AnsibleError(f"Could not connect to redis sentinel: {exc}")
|
||||
raise AnsibleError(f"Could not connect to redis sentinel: {exc}") from exc
|
||||
|
||||
def _make_key(self, key):
|
||||
return self._prefix + key
|
||||
|
||||
Reference in New Issue
Block a user