Corrected a display error when showing error context.

This commit is contained in:
John Wiegley 2009-02-03 00:45:14 -04:00
parent b52e9cf41b
commit ad34a71646
2 changed files with 14 additions and 5 deletions

View file

@ -133,8 +133,12 @@ int main(int argc, char * argv[], char * envp[])
}
catch (const std::exception& err) {
std::cout.flush(); // first display anything that was pending
std::cerr << error_context() << std::endl
<< "Error: " << err.what() << std::endl;
string context = error_context();
if (! context.empty())
std::cerr << context << std::endl;
std::cerr << "Error: " << err.what() << std::endl;
}
catch (int _status) {
status = _status; // used for a "quick" exit, and is used only

View file

@ -208,9 +208,14 @@ void textual_parser_t::instance_t::parse()
add_error_context("While parsing file "
<< file_context(pathname, linenum - 1));
std::cerr << error_context() << std::endl
<< current_context << std::endl
<< "Error: " << err.what() << std::endl;
string context = error_context();
if (! context.empty())
std::cerr << context << std::endl;
if (! current_context.empty())
std::cerr << current_context << std::endl;
std::cerr << "Error: " << err.what() << std::endl;
errors++;
}
}