Merge "Do not use asserts with business logic"

This commit is contained in:
Zuul 2018-02-01 20:38:35 +00:00 committed by Gerrit Code Review
commit 8499dd4be9
1 changed files with 3 additions and 2 deletions

View File

@ -148,8 +148,9 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
continue
try:
int_value = int(value)
assert int_value >= 0
except (ValueError, AssertionError):
if int_value < 0:
raise ValueError("Value must be non-negative")
except (ValueError, TypeError):
msg = (('%(param)s=%(value)s') %
{'param': param, 'value': value})
invalid_msgs_list.append(msg)