From 9c664f424e45163232f936bd96e55876de338f70 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Sun, 2 Oct 2016 16:46:38 -0400 Subject: [PATCH] adds exception handling for adding an invalid condition (#5125) This change will now handle a problem adding a condition that raises an AddConditionError and return a well formed error to the user. --- lib/ansible/modules/network/junos/junos_command.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/network/junos/junos_command.py b/lib/ansible/modules/network/junos/junos_command.py index 02b2a04e7b0..6fc2b0a4ef3 100644 --- a/lib/ansible/modules/network/junos/junos_command.py +++ b/lib/ansible/modules/network/junos/junos_command.py @@ -158,7 +158,7 @@ from ansible.module_utils.basic import get_exception from ansible.module_utils.network import NetworkModule, NetworkError from ansible.module_utils.netcli import CommandRunner from ansible.module_utils.netcli import AddCommandError, FailedConditionsError -from ansible.module_utils.netcli import FailedConditionalError +from ansible.module_utils.netcli import FailedConditionalError, AddConditionError from ansible.module_utils.junos import xml_to_json from ansible.module_utils.six import string_types @@ -261,9 +261,9 @@ def main(): try: for item in conditionals: runner.add_conditional(item) - except (ValueError, AttributeError): + except (ValueError, AddConditionError): exc = get_exception() - module.fail_json(msg=str(exc)) + module.fail_json(msg=str(exc), condition=exc.condition) runner.retries = module.params['retries'] runner.interval = module.params['interval']