summaryrefslogtreecommitdiff
path: root/swift/common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'swift/common/utils.py')
-rw-r--r--swift/common/utils.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/swift/common/utils.py b/swift/common/utils.py
index 8a409c960..b0fef4419 100644
--- a/swift/common/utils.py
+++ b/swift/common/utils.py
@@ -325,9 +325,13 @@ def non_negative_float(value):
:raises ValueError: if the value cannot be cast to a float or is negative.
:return: a float
"""
- value = float(value)
- if value < 0:
- raise ValueError
+ try:
+ value = float(value)
+ if value < 0:
+ raise ValueError
+ except (TypeError, ValueError):
+ raise ValueError('Value must be a non-negative float number, not "%s".'
+ % value)
return value