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

Tweak error language in dict validation

This commit is contained in:
James Cammarata 2014-08-21 13:24:53 -05:00
parent 3a228b9d55
commit b81e77cfec

View file

@ -699,16 +699,20 @@ def parse_kv(args):
def _validate_both_dicts(a, b): def _validate_both_dicts(a, b):
if not (isinstance(a, dict) and isinstance(b, dict)): if not (isinstance(a, dict) and isinstance(b, dict)):
raise errors.AnsibleError("Failed to combine two values which are not " raise errors.AnsibleError(
"both hashes, got these differing values now:\n\n%s\n and\n%s" % (a, b)) "failed to combine variables, expected dicts but got a '%s' and a '%s'" % (type(a).__name__, type(b).__name__)
)
def merge_hash(a, b): def merge_hash(a, b):
''' recursively merges hash b into a ''' recursively merges hash b into a
keys from b take precedence over keys from a ''' keys from b take precedence over keys from a '''
_validate_both_dicts(a, b)
result = {} result = {}
# we check here as well as in combine_vars() since this
# function can work recursively with nested dicts
_validate_both_dicts(a, b)
for dicts in a, b: for dicts in a, b:
# next, iterate over b keys and values # next, iterate over b keys and values
for k, v in dicts.iteritems(): for k, v in dicts.iteritems():