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:
parent
7610b82e00
commit
9bbf6efe28
1 changed files with 11 additions and 9 deletions
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue