Improved an error message that was trying to show transaction context.
This commit is contained in:
parent
4f5799c216
commit
02bd9d29cf
4 changed files with 5 additions and 7 deletions
|
|
@ -222,7 +222,7 @@ bool entry_base_t::finalize()
|
|||
DEBUG("entry.finalize", "final balance = " << balance);
|
||||
|
||||
if (! balance.is_null() && ! balance.is_zero()) {
|
||||
add_error_context(item_context(*this));
|
||||
add_error_context(item_context(*this, "While balancing entry"));
|
||||
add_error_context("Unbalanced remainder is:");
|
||||
add_error_context(value_context(balance));
|
||||
throw_(balance_error, "Entry does not balance");
|
||||
|
|
|
|||
|
|
@ -198,8 +198,7 @@ void calc_xacts::operator()(xact_t& xact)
|
|||
last_xact = &xact;
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
add_error_context("While calculating transaction:");
|
||||
add_error_context(item_context(xact));
|
||||
add_error_context(item_context(xact, "While calculating transaction"));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ bool item_t::valid() const
|
|||
return true;
|
||||
}
|
||||
|
||||
string item_context(const item_t& item)
|
||||
string item_context(const item_t& item, const string& desc)
|
||||
{
|
||||
std::size_t len = item.end_pos - item.beg_pos;
|
||||
assert(len > 0);
|
||||
|
|
@ -342,8 +342,7 @@ string item_context(const item_t& item)
|
|||
|
||||
std::ostringstream out;
|
||||
|
||||
out << "While balancing item from \"" << item.pathname.string()
|
||||
<< "\"";
|
||||
out << desc << " from \"" << item.pathname.string() << "\"";
|
||||
|
||||
if (item.beg_line != item.end_line)
|
||||
out << ", lines " << item.beg_line << "-"
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ public:
|
|||
|
||||
value_t get_comment(item_t& item);
|
||||
|
||||
string item_context(const item_t& item);
|
||||
string item_context(const item_t& item, const string& desc);
|
||||
|
||||
} // namespace ledger
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue