mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
adds check for AddConditionError when adding conditional statements (#5123)
The Conditional instance will now raise the AddConditionError and this change instructs eos_command to catch the error and return a nicely formed error message
This commit is contained in:
parent
48b0cb750c
commit
f5e72c6590
1 changed files with 8 additions and 3 deletions
|
@ -149,7 +149,7 @@ import ansible.module_utils.eos
|
|||
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
|
||||
from ansible.module_utils.netcli import AddCommandError, AddConditionError
|
||||
from ansible.module_utils.netcli import FailedConditionsError
|
||||
from ansible.module_utils.netcli import FailedConditionalError
|
||||
from ansible.module_utils.six import string_types
|
||||
|
@ -212,8 +212,13 @@ def main():
|
|||
exc = get_exception()
|
||||
warnings.append('duplicate command detected: %s' % cmd)
|
||||
|
||||
try:
|
||||
for item in conditionals:
|
||||
runner.add_conditional(item)
|
||||
except AddConditionError:
|
||||
exc = get_exception()
|
||||
module.fail_json(msg=str(exc), condition=exc.condition)
|
||||
|
||||
|
||||
runner.retries = module.params['retries']
|
||||
runner.interval = module.params['interval']
|
||||
|
|
Loading…
Reference in a new issue