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 /binary.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 'binary.cc')
-rw-r--r-- | binary.cc | 32 |
1 files changed, 26 insertions, 6 deletions
@@ -621,9 +621,29 @@ unsigned int read_binary_journal(std::istream& in, std::pair<base_commodities_map::iterator, bool> result = commodity_base_t::commodities.insert (base_commodities_pair(commodity->symbol, commodity)); - if (! result.second) - throw error(std::string("Failed to read base commodity from cache: ") + - commodity->symbol); + if (! result.second) { + base_commodities_map::iterator c = + commodity_base_t::commodities.find(commodity->symbol); + + // It's possible the user might have used a commodity in a value + // expression passed to an option, we'll just override the + // flags, but keep the commodity pointer intact. + if (c == commodity_base_t::commodities.end() || + (*c).second->history || (*c).second->smaller || + (*c).second->larger) + throw new error(std::string("Failed to read base commodity from cache: ") + + commodity->symbol); + + (*c).second->name = commodity->name; + (*c).second->note = commodity->note; + (*c).second->precision = commodity->precision; + (*c).second->flags = commodity->flags; + (*c).second->history = commodity->history; + (*c).second->smaller = commodity->smaller; + (*c).second->larger = commodity->larger; + + *(base_commodities_next - 1) = (*c).second; + } } for (commodity_base_t::ident_t i = 0; i < bc_count; i++) @@ -655,9 +675,9 @@ unsigned int read_binary_journal(std::istream& in, std::pair<commodities_map::iterator, bool> result = commodity_t::commodities.insert(commodities_pair(mapping_key, commodity)); - if (! result.second) - throw error(std::string("Failed to read commodity from cache: ") + - commodity->ptr->symbol); + if (! result.second && commodity->annotated) + throw new error(std::string("Failed to read commodity from cache: ") + + commodity->ptr->symbol); } commodity_t::ident_t ident; |