diff options
author | John Wiegley <johnw@newartisans.com> | 2006-03-08 18:24:56 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:41:29 -0400 |
commit | e32d9e64a768f276e04fe79c14f1b28d88bd4185 (patch) | |
tree | 198f0b5a65a2eeb6f1f0a61dc59bf5111e7ae50d /journal.cc | |
parent | b737cd8e6dd185beeae902caa4eee6c4cee8bc36 (diff) | |
download | fork-ledger-e32d9e64a768f276e04fe79c14f1b28d88bd4185.tar.gz fork-ledger-e32d9e64a768f276e04fe79c14f1b28d88bd4185.tar.bz2 fork-ledger-e32d9e64a768f276e04fe79c14f1b28d88bd4185.zip |
Added much better error location.
Diffstat (limited to 'journal.cc')
-rw-r--r-- | journal.cc | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -79,15 +79,13 @@ bool entry_base_t::remove_transaction(transaction_t * xact) return true; } -value_t entry_balance; - bool entry_base_t::finalize() { // Scan through and compute the total balance for the entry. This // is used for auto-calculating the value of entries with no cost, // and the per-unit price of unpriced commodities. - value_t& balance = entry_balance; + value_t balance; bool no_amounts = true; for (transactions_list::const_iterator x = transactions.begin(); @@ -106,7 +104,8 @@ bool entry_base_t::finalize() if ((*x)->cost && (*x)->amount.commodity().annotated) { annotated_commodity_t& - ann_comm(static_cast<annotated_commodity_t&>((*x)->amount.commodity())); + ann_comm(static_cast<annotated_commodity_t&> + ((*x)->amount.commodity())); if (ann_comm.price) balance += ann_comm.price * (*x)->amount - *((*x)->cost); } @@ -240,7 +239,16 @@ bool entry_base_t::finalize() } } - return ! balance; + if (balance) { + error * err = + new balance_error("Entry does not balance", + new entry_context(*this, "While balancing entry:")); + err->context.push_front + (new value_context(balance, "Unbalanced remainder is:")); + throw err; + } + + return true; } entry_t::entry_t(const entry_t& e) |