diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-13 00:42:25 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-13 00:42:25 -0400 |
commit | 40f553228f5a28034c6635fdcb4c86af28a385ed (patch) | |
tree | 2c40305c9f9841a4c3d453a4a5c49ec69056b4b2 /src/expr.cc | |
parent | 556211e623cad88213e5087b5c9c36e754d9aa02 (diff) | |
parent | b1b4e2aadff5983d443d70c09ea86a41b015873f (diff) | |
download | fork-ledger-40f553228f5a28034c6635fdcb4c86af28a385ed.tar.gz fork-ledger-40f553228f5a28034c6635fdcb4c86af28a385ed.tar.bz2 fork-ledger-40f553228f5a28034c6635fdcb4c86af28a385ed.zip |
Merge branch 'next'
Diffstat (limited to 'src/expr.cc')
-rw-r--r-- | src/expr.cc | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/src/expr.cc b/src/expr.cc index f3a30de6..defa5b79 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -37,7 +37,7 @@ namespace ledger { void expr_t::parse(std::istream& in, const parse_flags_t& flags, - const optional<string>& original_string) + const optional<string>& original_string) { parser_t parser; istream_pos_type start_pos = in.tellg(); @@ -78,31 +78,36 @@ value_t expr_t::real_calc(scope_t& scope) } catch (const std::exception& err) { if (locus) { - add_error_context(_("While evaluating value expression:")); - add_error_context(op_context(ptr, locus)); - - if (SHOW_INFO()) { - add_error_context(_("The value expression tree was:")); - std::ostringstream buf; - ptr->dump(buf, 0); - - std::istringstream in(buf.str()); - std::ostringstream out; - char linebuf[1024]; - bool first = true; - while (in.good() && ! in.eof()) { - in.getline(linebuf, 1023); - std::streamsize len = in.gcount(); - if (len > 0) { - if (first) - first = false; - else - out << '\n'; - out << " " << linebuf; - } - } - add_error_context(out.str()); - } + string current_context = error_context(); + + add_error_context(_("While evaluating value expression:")); + add_error_context(op_context(ptr, locus)); + + if (SHOW_INFO()) { + add_error_context(_("The value expression tree was:")); + std::ostringstream buf; + ptr->dump(buf, 0); + + std::istringstream in(buf.str()); + std::ostringstream out; + char linebuf[1024]; + bool first = true; + while (in.good() && ! in.eof()) { + in.getline(linebuf, 1023); + std::streamsize len = in.gcount(); + if (len > 0) { + if (first) + first = false; + else + out << '\n'; + out << " " << linebuf; + } + } + add_error_context(out.str()); + } + + if (! current_context.empty()) + add_error_context(current_context); } throw; } |