Merge "Remove logging of exceptions from types module"
This commit is contained in:
commit
f4781978a7
@ -38,17 +38,14 @@ class String(object):
|
|||||||
def validate(cls, value, min_length=0, max_length=None):
|
def validate(cls, value, min_length=0, max_length=None):
|
||||||
if value is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
strlen = len(value)
|
strlen = len(value)
|
||||||
if strlen < min_length:
|
if strlen < min_length:
|
||||||
raise TypeError('String length is less than' + min_length)
|
raise ValueError('String length is less than ' + min_length)
|
||||||
if max_length and strlen > max_length:
|
if max_length and strlen > max_length:
|
||||||
raise TypeError('String length is greater than' + max_length)
|
raise ValueError('String length is greater than ' + max_length)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
raise ValueError("An invalid value was provided")
|
raise ValueError("An invalid value was provided")
|
||||||
except ValueError as e:
|
|
||||||
raise ValueError(str(e))
|
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@ -65,7 +62,6 @@ class Integer(object):
|
|||||||
try:
|
try:
|
||||||
value = int(value)
|
value = int(value)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('Failed to convert value to int')
|
|
||||||
raise ValueError("Failed to convert value to int")
|
raise ValueError("Failed to convert value to int")
|
||||||
|
|
||||||
if minimum is not None and value < minimum:
|
if minimum is not None and value < minimum:
|
||||||
@ -88,7 +84,6 @@ class Bool(object):
|
|||||||
try:
|
try:
|
||||||
value = value.lower() in ("yes", "true", "t", "1")
|
value = value.lower() in ("yes", "true", "t", "1")
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('Failed to convert value to bool')
|
|
||||||
raise ValueError("Failed to convert value to bool")
|
raise ValueError("Failed to convert value to bool")
|
||||||
|
|
||||||
return value
|
return value
|
||||||
@ -108,7 +103,6 @@ class Custom(object):
|
|||||||
try:
|
try:
|
||||||
value = self.user_class(**value)
|
value = self.user_class(**value)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('Failed to validate received value')
|
|
||||||
raise ValueError("Failed to validate received value")
|
raise ValueError("Failed to validate received value")
|
||||||
|
|
||||||
return value
|
return value
|
||||||
@ -130,5 +124,4 @@ class List(object):
|
|||||||
try:
|
try:
|
||||||
return [self.type.validate(v) for v in value]
|
return [self.type.validate(v) for v in value]
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('Failed to validate received value')
|
|
||||||
raise ValueError("Failed to validate received value")
|
raise ValueError("Failed to validate received value")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user