Skip to content

Commit

Permalink
Limit ObjectSelector error message by characters
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 27, 2017
1 parent 12705ec commit fc894b0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions param/__init__.py
Expand Up @@ -1030,12 +1030,18 @@ def _check_value(self,val,obj=None):
except AttributeError:
attrib_name = ""

items = self.objects
items = []
limiter = ']'
if len(items) > 20:
items = items[:20]
limiter = ', ...]'
items = '[' + ', '.join(map(str, items)) + limiter
length = 0
for item in self.objects:
string = str(item)
length += len(string)
if length < 200:
items.append(string)
else:
limiter = ', ...]'
break
items = '[' + ', '.join(items) + limiter
raise ValueError("%s not in Parameter %s's list of possible objects, "
"valid options include %s"%(val,attrib_name, items))

Expand Down

0 comments on commit fc894b0

Please sign in to comment.