1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-22 13:19:13 +00:00

uv_python module: improve exception handling

This commit is contained in:
Mariam Ahhttouche 2026-02-16 11:42:49 +01:00
parent 7610b82e00
commit 9bbf6efe28

View file

@ -146,17 +146,19 @@ def main():
msg="",
)
state = module.params["state"]
uv = UV(module)
if state == "present":
result["changed"], result["msg"] = uv.install_python()
elif state == "absent":
result["changed"], result["msg"] = uv.uninstall_python()
elif state == "latest":
result["changed"], result["msg"] = uv.upgrade_python()
module.exit_json(**result)
try:
uv = UV(module)
if state == "present":
result["changed"], result["msg"] = uv.install_python()
elif state == "absent":
result["changed"], result["msg"] = uv.uninstall_python()
elif state == "latest":
result["changed"], result["msg"] = uv.upgrade_python()
module.exit_json(**result)
except Exception as e:
module.fail_json(msg=str(e))
if __name__ == "__main__":
main()