From 1ceed020484026b631f454ab07df9dc573e8d94d Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 25 May 2021 13:59:51 +0200 Subject: [PATCH] Use str() to get exception message (#2590) (#2610) (cherry picked from commit 63012eef82ad127e06e7a3e5a51eeb7a0f30a0c3) Co-authored-by: DasSkelett --- .../fragments/2590-netcup_dns-exception-no-message-attr.yml | 2 ++ plugins/modules/net_tools/netcup_dns.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/2590-netcup_dns-exception-no-message-attr.yml diff --git a/changelogs/fragments/2590-netcup_dns-exception-no-message-attr.yml b/changelogs/fragments/2590-netcup_dns-exception-no-message-attr.yml new file mode 100644 index 0000000000..06cac9ad1b --- /dev/null +++ b/changelogs/fragments/2590-netcup_dns-exception-no-message-attr.yml @@ -0,0 +1,2 @@ +bugfixes: + - netcup_dns - use ``str(ex)`` instead of unreliable ``ex.message`` in exception handling to fix ``AttributeError`` in error cases (https://github.com/ansible-collections/community.general/pull/2590). diff --git a/plugins/modules/net_tools/netcup_dns.py b/plugins/modules/net_tools/netcup_dns.py index 5d63a5b38e..5ec5cbb246 100644 --- a/plugins/modules/net_tools/netcup_dns.py +++ b/plugins/modules/net_tools/netcup_dns.py @@ -255,7 +255,7 @@ def main(): has_changed = True except Exception as ex: - module.fail_json(msg=ex.message) + module.fail_json(msg=str(ex)) module.exit_json(changed=has_changed, result={"records": [record_data(r) for r in all_records]})