Skip to content

Commit 82ed96c

Browse files
committed
[property] Specify ValueError Message
If format of value is wrong, e.g. with date, more info is given.
1 parent 1231d2f commit 82ed96c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

odml/property.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ def _validate_values(self, values):
247247
try:
248248
dtypes.get(v, self.dtype)
249249
except Exception:
250+
raise ValueError("odml.Property.values: passed value \'%s\' are not of "
251+
"consistent type \'%s\'! Format should be \'%s\'." %
252+
(v, self._dtype, dtypes.default_values(self._dtype)))
250253
return False
251254
return True
252255

@@ -327,9 +330,7 @@ def values(self, new_value):
327330
if self._dtype is None:
328331
self._dtype = dtypes.infer_dtype(new_value[0])
329332

330-
if not self._validate_values(new_value):
331-
raise ValueError("odml.Property.values: passed values are not of "
332-
"consistent type!")
333+
self._validate_values(new_value)
333334
self._values = [dtypes.get(v, self.dtype) for v in new_value]
334335

335336
@property

0 commit comments

Comments
 (0)