1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

Use raise from in plugins (#11095)

* Use raise from.

* Add changelog fragment.
This commit is contained in:
Felix Fontein 2025-11-12 20:34:26 +01:00 committed by GitHub
parent 1a82e93c6d
commit 2b4333a033
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
46 changed files with 218 additions and 165 deletions

View file

@ -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