Skip to content

Commit

Permalink
Make check_match() errors more readable for ListOf objects
Browse files Browse the repository at this point in the history
When the ListOf object's check_match() fails due to an incompatible object
having been passed, the salient information for the error message is the
type of the passed object and the type of the object against which the
check_match() method was called, therefore print those types in the error
messsage and not the string representation of the objects.

Fixes #194

Signed-off-by: Joshua Lock <[email protected]>
  • Loading branch information
joshuagl committed Jan 6, 2020
1 parent 536c7f2 commit 31b9a2a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion securesystemslib/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ def __init__(self, schema, min_count=0, max_count=sys.maxsize, list_name='list')
def check_match(self, object):
if not isinstance(object, (list, tuple)):
raise securesystemslib.exceptions.FormatError(
'Expected ' + repr(self._list_name) + ' but got ' + repr(object))
'Expected object of type %s but got type %s'
% (type(self._list_name), type(object)))


# Check if all the items in the 'object' list
Expand Down

0 comments on commit 31b9a2a

Please sign in to comment.