Skip to content

Commit

Permalink
Improved error message on TypedList and EntityList
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Worrell committed Mar 3, 2015
1 parent ecf0558 commit a627651
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions stix/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@ def _fix_value(self, value):
try:
new_value = self._contained_type(value)
except:
raise ValueError("Can't put '%s' (%s) into a %s" %
(value, type(value), self.__class__))
error = "Can't put '{0}' ({1}) into a {2}. Expected {3} instance."
error = error.format(value, type(value), type(self), type(self._contained_type))
raise ValueError(error)

return new_value

# The next four functions can be overridden, but otherwise define the
Expand Down Expand Up @@ -432,8 +434,8 @@ def _fix_value(self, value):
try:
new_value = self._contained_type(value)
except:
error = "Can't put '{0}' ({1}) into a {3}"
error = error.format(value, type(value), self.__class__)
error = "Can't put '{0}' ({1}) into a {2}. Expected {3} instance."
error = error.format(value, type(value), type(self), type(self._contained_type))
raise ValueError(error)

return new_value
Expand Down

0 comments on commit a627651

Please sign in to comment.