summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-02 15:16:18 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-02 15:16:18 -0400
commitcf9b4a38739426e4993fac49798ebe7dcfa11d62 (patch)
treedfd7e8afc40eaf6cf829026709771f5e32e62740
parentb18214372e42f84cd3c3b4ecfce8bb0295e6f9ca (diff)
downloadfork-ledger-cf9b4a38739426e4993fac49798ebe7dcfa11d62.tar.gz
fork-ledger-cf9b4a38739426e4993fac49798ebe7dcfa11d62.tar.bz2
fork-ledger-cf9b4a38739426e4993fac49798ebe7dcfa11d62.zip
Removed report_error() function and reordered context for parsing errors.
-rw-r--r--src/error.cc6
-rw-r--r--src/error.h2
-rw-r--r--src/main.cc3
-rw-r--r--src/textual.cc6
4 files changed, 7 insertions, 10 deletions
diff --git a/src/error.cc b/src/error.cc
index 8fc8fa53..68a2d844 100644
--- a/src/error.cc
+++ b/src/error.cc
@@ -75,10 +75,4 @@ string line_context(const string& line,
return buf.str();
}
-void report_error(const std::exception& err)
-{
- std::cerr << error_context() << std::endl
- << "Error: " << err.what() << std::endl;
-}
-
} // namespace ledger
diff --git a/src/error.h b/src/error.h
index d61490aa..4ff5a04c 100644
--- a/src/error.h
+++ b/src/error.h
@@ -72,8 +72,6 @@ string line_context(const string& line,
istream_pos_type pos = istream_pos_type(0),
istream_pos_type end_pos = istream_pos_type(0));
-void report_error(const std::exception& err);
-
#define DECLARE_EXCEPTION(name, kind) \
class name : public kind { \
public: \
diff --git a/src/main.cc b/src/main.cc
index 583c82cd..06bb2339 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -133,7 +133,8 @@ int main(int argc, char * argv[], char * envp[])
}
catch (const std::exception& err) {
std::cout.flush();
- report_error(err);
+ std::cerr << error_context() << std::endl
+ << "Error: " << err.what() << std::endl;
}
catch (int _status) {
status = _status;
diff --git a/src/textual.cc b/src/textual.cc
index b701233f..1be5d4d8 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -190,6 +190,8 @@ void textual_parser_t::instance_t::parse()
beg_line = linenum;
}
catch (const std::exception& err) {
+ string current_context = error_context();
+
if (parent) {
std::list<instance_t *> instances;
@@ -206,7 +208,9 @@ void textual_parser_t::instance_t::parse()
add_error_context("While parsing file "
<< file_context(pathname, linenum - 1));
- report_error(err);
+ std::cerr << error_context() << std::endl
+ << current_context << std::endl
+ << "Error: " << err.what() << std::endl;
errors++;
}
}