From aa2ff2b5db4afd28fc05e4cb0848d6cc1f0862e9 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 16 Apr 2014 15:56:30 -0500 Subject: Improve an error message relating to balance assertions --- src/textual.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/textual.cc') diff --git a/src/textual.cc b/src/textual.cc index d02e2f79..55f22a2c 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1609,22 +1609,25 @@ post_t * instance_t::parse_post(char * line, "line " << context.linenum << ": " << "post amount = " << amt); amount_t diff = amt; + amount_t tot; switch (account_total.type()) { case value_t::AMOUNT: - diff -= account_total.as_amount(); + tot = account_total.as_amount(); break; case value_t::BALANCE: if (optional comm_bal = account_total.as_balance().commodity_amount(amt.commodity())) - diff -= *comm_bal; + tot = *comm_bal; break; default: break; } + diff -= tot; + DEBUG("post.assign", "line " << context.linenum << ": " << "diff = " << diff); DEBUG("textual.parse", "line " << context.linenum << ": " @@ -1634,7 +1637,9 @@ post_t * instance_t::parse_post(char * line, if (! post->amount.is_null()) { diff -= post->amount; if (! no_assertions && ! diff.is_zero()) - throw_(parse_error, _f("Balance assertion off by %1%") % diff); + throw_(parse_error, + _f("Balance assertion off by %1% (expected to see %2%)") + % diff % tot); } else { post->amount = diff; DEBUG("textual.parse", "line " << context.linenum << ": " -- cgit v1.2.3