[core] desc: use explicit message in validateValue exceptions

This commit is contained in:
Fabien Castan 2017-11-10 11:37:59 +01:00
parent cb29e02c0a
commit 848229778e

View file

@ -45,7 +45,7 @@ class ListAttribute(Attribute):
def validateValue(self, value):
if not (isinstance(value, collections.Iterable) and isinstance(value, basestring)):
raise ValueError('ListAttribute only supports iterable input values.')
raise ValueError('ListAttribute only supports iterable input values (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
return value
@ -60,7 +60,7 @@ class GroupAttribute(Attribute):
def validateValue(self, value):
if not (isinstance(value, collections.Iterable) and isinstance(value, basestring)):
raise ValueError('GroupAttribute only supports iterable input values.')
raise ValueError('GroupAttribute only supports iterable input values (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
return value
def retrieveChildrenUids(self):
@ -87,7 +87,7 @@ class File(Attribute):
def validateValue(self, value):
if not isinstance(value, basestring):
raise ValueError('File only supports string input: "{}".'.format(value))
raise ValueError('File only supports string input (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
return os.path.normpath(value).replace('\\', '/')
@ -101,7 +101,7 @@ class BoolParam(Param):
try:
return bool(value)
except:
raise ValueError('BoolParam only supports bool value.')
raise ValueError('BoolParam only supports bool value (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
class IntParam(Param):
@ -115,7 +115,7 @@ class IntParam(Param):
try:
return int(value)
except:
raise ValueError('IntParam only supports int value.')
raise ValueError('IntParam only supports int value (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
range = Property(Variant, lambda self: self._range, constant=True)
@ -131,7 +131,7 @@ class FloatParam(Param):
try:
return float(value)
except:
raise ValueError('FloatParam only supports float value.')
raise ValueError('FloatParam only supports float value (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
range = Property(Variant, lambda self: self._range, constant=True)
@ -151,7 +151,7 @@ class ChoiceParam(Param):
newValues = [value]
else:
if not isinstance(value, collections.Iterable):
raise ValueError('Non exclusive ChoiceParam value "{}" should be iterable.'.format(value))
raise ValueError('Non exclusive ChoiceParam value should be iterable (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
newValues = value
for newValue in newValues:
if newValue not in self.values:
@ -171,7 +171,7 @@ class StringParam(Param):
def validateValue(self, value):
if not isinstance(value, basestring):
raise ValueError('StringParam value "{}" should be a string.'.format(value))
raise ValueError('StringParam value should be a string (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
return value