1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Catch the raised exception so we can report failure (#42072)

Avoid the _undefined name_ and mirror lines 389 and 459 by catching the raised exception in the variable __exc__ so it can be reported on the following line.

flake8 testing of https://github.com/ansible/ansible on Python 3.6.3

$ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__
```
./lib/ansible/module_utils/network/iosxr/iosxr.py:414:42: F821 undefined name 'exc'
            module.fail_json(msg=to_text(exc))
                                         ^
```
This commit is contained in:
cclauss 2018-07-02 06:06:11 +02:00 committed by Trishna Guha
parent 52e7946de5
commit 61d5454737

View file

@ -410,7 +410,7 @@ def load_config(module, command_filter, commit=False, replace=False,
try:
conn.edit_config(cmd_filter)
except ConnectionError:
except ConnectionError as exc:
module.fail_json(msg=to_text(exc))
if module._diff: