From 63d027238564c2cafa70184c46dbdcdf1854aee5 Mon Sep 17 00:00:00 2001
From: Rafael Guterres Jeffman <rjeffman@redhat.com>
Date: Wed, 12 Jul 2023 18:36:48 -0300
Subject: [PATCH] Change 'Exception' to 'RuntimeError' when FreeIPA version is
 too old

Changing the use of 'Exception' to 'RuntimeError' has the benefits of
making the error more specific and meaningful for what is being reported
and to remove warnings from linters (pylint).

The same change is applied to all deployment roles.
---
 roles/ipaclient/module_utils/ansible_ipa_client.py   | 3 +--
 roles/ipareplica/module_utils/ansible_ipa_replica.py | 3 +--
 roles/ipaserver/module_utils/ansible_ipa_server.py   | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/roles/ipaclient/module_utils/ansible_ipa_client.py b/roles/ipaclient/module_utils/ansible_ipa_client.py
index 3116c7de..5853f6ba 100644
--- a/roles/ipaclient/module_utils/ansible_ipa_client.py
+++ b/roles/ipaclient/module_utils/ansible_ipa_client.py
@@ -307,8 +307,7 @@ try:
 
     else:
         # IPA version < 4.4
-
-        raise Exception("freeipa version '%s' is too old" % VERSION)
+        raise RuntimeError("freeipa version '%s' is too old" % VERSION)
 
 except ImportError as _err:
     ANSIBLE_IPA_CLIENT_MODULE_IMPORT_ERROR = str(_err)
diff --git a/roles/ipareplica/module_utils/ansible_ipa_replica.py b/roles/ipareplica/module_utils/ansible_ipa_replica.py
index fb168010..76b7be2d 100644
--- a/roles/ipareplica/module_utils/ansible_ipa_replica.py
+++ b/roles/ipareplica/module_utils/ansible_ipa_replica.py
@@ -171,8 +171,7 @@ try:
 
     else:
         # IPA version < 4.6
-
-        raise Exception("freeipa version '%s' is too old" % VERSION)
+        raise RuntimeError("freeipa version '%s' is too old" % VERSION)
 
 except ImportError as _err:
     ANSIBLE_IPA_REPLICA_MODULE_IMPORT_ERROR = str(_err)
diff --git a/roles/ipaserver/module_utils/ansible_ipa_server.py b/roles/ipaserver/module_utils/ansible_ipa_server.py
index 80e2042c..8bdb048b 100644
--- a/roles/ipaserver/module_utils/ansible_ipa_server.py
+++ b/roles/ipaserver/module_utils/ansible_ipa_server.py
@@ -212,8 +212,7 @@ try:
 
     else:
         # IPA version < 4.5
-
-        raise Exception("freeipa version '%s' is too old" % VERSION)
+        raise RuntimeError("freeipa version '%s' is too old" % VERSION)
 
 except ImportError as _err:
     ANSIBLE_IPA_SERVER_MODULE_IMPORT_ERROR = str(_err)
-- 
GitLab