summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/entry.cc2
-rw-r--r--src/filters.cc3
-rw-r--r--src/item.cc5
-rw-r--r--src/item.h2
4 files changed, 5 insertions, 7 deletions
diff --git a/src/entry.cc b/src/entry.cc
index 5082b34a..f8166559 100644
--- a/src/entry.cc
+++ b/src/entry.cc
@@ -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");
diff --git a/src/filters.cc b/src/filters.cc
index a0d65478..b19c36f1 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -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;
}
}
diff --git a/src/item.cc b/src/item.cc
index 8bd2471b..cb69909f 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -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 << "-"
diff --git a/src/item.h b/src/item.h
index a301b863..85dbf7ed 100644
--- a/src/item.h
+++ b/src/item.h
@@ -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