summaryrefslogtreecommitdiff
path: root/textutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'textutils.py')
-rw-r--r--textutils.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/textutils.py b/textutils.py
index 38f59c7..37d4f48 100644
--- a/textutils.py
+++ b/textutils.py
@@ -289,7 +289,11 @@ def apply_units( string, units, inter=None, final=float, blank_reg=_BLANK_RE,
lit, unit = dic["value"], dic.get("unit")
value = inter(lit)
if unit is not None:
- value *= units[unit]
+ try:
+ value *= units[unit]
+ except KeyError:
+ raise KeyError('invalid unit %s. valid units are %s' %
+ unit, units.keys())
values.append(value)
return final(sum(values))