diff options
-rw-r--r-- | talerbank/app/amount.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/talerbank/app/amount.py b/talerbank/app/amount.py index 6c17610..0453c35 100644 --- a/talerbank/app/amount.py +++ b/talerbank/app/amount.py @@ -23,11 +23,16 @@ # which might need it. class CurrencyMismatch(Exception): - pass + def __init__(self, msg): + self.msg = msg + def __str__(self): + return self.msg class BadFormatAmount(Exception): def __init__(self, faulty_str): self.faulty_str = faulty_str + def __str__(self): + return self.faulty_str class Amount: # How many "fraction" units make one "value" unit of currency @@ -77,7 +82,7 @@ class Amount: @staticmethod def cmp(am1, am2): if am1.currency != am2.currency: - raise CurrencyMismatch() + raise CurrencyMismatch("%s vs %s" % (am1.currency, am2.currency)) if am1.value == am2.value: if am1.fraction < am2.fraction: return -1 |