diff options
author | John Wiegley <johnw@newartisans.com> | 2014-04-16 15:56:30 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2014-04-16 15:56:30 -0500 |
commit | aa2ff2b5db4afd28fc05e4cb0848d6cc1f0862e9 (patch) | |
tree | 036542dd4d7331b709c6eec28bb924adc9d10476 /src/textual.cc | |
parent | f73ff40a8671f323c277197417f18af989087950 (diff) | |
download | fork-ledger-aa2ff2b5db4afd28fc05e4cb0848d6cc1f0862e9.tar.gz fork-ledger-aa2ff2b5db4afd28fc05e4cb0848d6cc1f0862e9.tar.bz2 fork-ledger-aa2ff2b5db4afd28fc05e4cb0848d6cc1f0862e9.zip |
Improve an error message relating to balance assertions
Diffstat (limited to 'src/textual.cc')
-rw-r--r-- | src/textual.cc | 11 |
1 files changed, 8 insertions, 3 deletions
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<amount_t> 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 << ": " |