From 340ff310757f133ac47b8bcbc68e610982cd0b7a Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Tue, 27 Sep 2016 20:59:40 -0400 Subject: [PATCH] catches exception if conditional cannot be parsed (#5067) If the conditional cannot be parsed, the module will now catch the exception and return a well formed failed message. fixes #5060 --- network/junos/junos_command.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/network/junos/junos_command.py b/network/junos/junos_command.py index fb80f0acad2..f370ace3d8a 100644 --- a/network/junos/junos_command.py +++ b/network/junos/junos_command.py @@ -263,8 +263,12 @@ def main(): exc = get_exception() warnings.append('duplicate command detected: %s' % cmd) - for item in conditionals: - runner.add_conditional(item) + try: + for item in conditionals: + runner.add_conditional(item) + except (ValueError, AttributeError): + exc = get_exception() + module.fail_json(msg=str(exc)) runner.retries = module.params['retries'] runner.interval = module.params['interval']