Removed report_error() function and reordered context for parsing errors.

This commit is contained in:
John Wiegley 2009-02-02 15:16:18 -04:00
parent b18214372e
commit cf9b4a3873
4 changed files with 7 additions and 10 deletions

View file

@ -75,10 +75,4 @@ string line_context(const string& line,
return buf.str(); return buf.str();
} }
void report_error(const std::exception& err)
{
std::cerr << error_context() << std::endl
<< "Error: " << err.what() << std::endl;
}
} // namespace ledger } // namespace ledger

View file

@ -72,8 +72,6 @@ string line_context(const string& line,
istream_pos_type pos = istream_pos_type(0), istream_pos_type pos = istream_pos_type(0),
istream_pos_type end_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) \ #define DECLARE_EXCEPTION(name, kind) \
class name : public kind { \ class name : public kind { \
public: \ public: \

View file

@ -133,7 +133,8 @@ int main(int argc, char * argv[], char * envp[])
} }
catch (const std::exception& err) { catch (const std::exception& err) {
std::cout.flush(); std::cout.flush();
report_error(err); std::cerr << error_context() << std::endl
<< "Error: " << err.what() << std::endl;
} }
catch (int _status) { catch (int _status) {
status = _status; status = _status;

View file

@ -190,6 +190,8 @@ void textual_parser_t::instance_t::parse()
beg_line = linenum; beg_line = linenum;
} }
catch (const std::exception& err) { catch (const std::exception& err) {
string current_context = error_context();
if (parent) { if (parent) {
std::list<instance_t *> instances; std::list<instance_t *> instances;
@ -206,7 +208,9 @@ void textual_parser_t::instance_t::parse()
add_error_context("While parsing file " add_error_context("While parsing file "
<< file_context(pathname, linenum - 1)); << file_context(pathname, linenum - 1));
report_error(err); std::cerr << error_context() << std::endl
<< current_context << std::endl
<< "Error: " << err.what() << std::endl;
errors++; errors++;
} }
} }