Skip to content
Snippets Groups Projects
Commit 144da1a3 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add a cosmetic hack to avoid duplication of the 'error:' tag

This duplication can occur when intercepting a NormalError
parent d965b696
No related branches found
No related tags found
1 merge request!145git subrepo clone git@gitlab.com:OlMon/org-themes.git packages/org-themes
......@@ -102,8 +102,22 @@ parser(const std::string& filename)
catch (const ParseError& e) {
const auto p = e.positions().front();
std::string error_specifier = [] {
std::ostringstream os;
os << rang::style::bold << "error:" << rang::style::reset << ' ';
return os.str();
}();
std::string message = e.what();
// This is a cosmetic hack to avoid repetition of "error: " in
// output
if (message.substr(0, error_specifier.size()) == error_specifier) {
message = message.substr(error_specifier.size());
}
std::cerr << rang::style::bold << p.source << ':' << p.line << ':' << p.column << ": " << rang::style::reset
<< rang::fgB::red << "error: " << rang::fg::reset << rang::style::bold << e.what() << rang::style::reset
<< rang::fgB::red << "error: " << rang::fg::reset << rang::style::bold << message << rang::style::reset
<< '\n'
<< input.line_at(p) << '\n'
<< std::string(p.column - 1, ' ') << rang::fgB::yellow << '^' << rang::fg::reset << '\n';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment