Improve map_merge logging

Templates can be complex and contain multiple instances of
map_merges. Debugging this can be complex, so this change
aims to improve the mapping and help users determine where
the problem has occured.

With this change, instead of just saying an error occured,
we will now return the object that the error occurred with
and a note about it's type. This will allow for quick
identification of what the problem was.

Change-Id: I1c4da88029bbf1a3cfb58f5e21da28ec2912f924
This commit is contained in:
Brendan Shephard 2022-11-03 11:11:36 +10:00
parent f71308319a
commit 56d99bf658
1 changed files with 3 additions and 1 deletions

View File

@ -738,7 +738,9 @@ class MapMerge(function.Function):
elif isinstance(m, collections.abc.Mapping):
return m
else:
msg = _('Incorrect arguments: Items to merge must be maps.')
msg = _('Incorrect arguments: Items to merge must be maps. '
'{} is type {} instead of a dict'.format(
repr(m)[:200], type(m)))
raise TypeError(msg)
ret_map = {}