modules: Do not hide errors using IPA *_show command with Exception

When searching for objects with *_show IPA API command, most plugins
were hiding errors other than "ipalib_errors.NotFound" by handling the
broad exception Exception instead.

This patch uses "ipalib_errors.NotFound" whenever "*_show" is used so
that the only exception handled is when an object is not found. Other
errors will not be handled making the module break as expected.
This commit is contained in:
Rafael Guterres Jeffman
2024-12-02 22:58:51 -03:00
parent 8fc2de1673
commit 1c4b50fa51
16 changed files with 34 additions and 31 deletions

View File

@@ -138,7 +138,7 @@ def find_idview(module, name):
"""Find if a idview with the given name already exist."""
try:
_result = module.ipa_command("idview_show", name, {"all": True})
except Exception: # pylint: disable=broad-except
except ipalib_errors.NotFound:
# An exception is raised if idview name is not found.
return None
return _result["result"]