diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-10 02:25:49 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-10 02:25:49 -0500 |
commit | f49b7b2166b47c381ba251ccab503b0cde259b3e (patch) | |
tree | d472b6912e60597dded9960ba84b60170865b620 /src/expr.cc | |
parent | c8013c04d4be6df42decb70b5d41a2ce3aad9588 (diff) | |
download | fork-ledger-f49b7b2166b47c381ba251ccab503b0cde259b3e.tar.gz fork-ledger-f49b7b2166b47c381ba251ccab503b0cde259b3e.tar.bz2 fork-ledger-f49b7b2166b47c381ba251ccab503b0cde259b3e.zip |
If -v is used, valexpr errors are more informative
Diffstat (limited to 'src/expr.cc')
-rw-r--r-- | src/expr.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/expr.cc b/src/expr.cc index aa9a7b0e..c59f8a57 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -64,6 +64,29 @@ value_t expr_t::real_calc(scope_t& scope) 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()); + } } throw; } |