mirror of
https://github.com/NixOS/nix.git
synced 2024-11-23 07:12:27 +00:00
traces to bottom
This commit is contained in:
parent
54e8f550c9
commit
13e87535ff
@ -284,21 +284,20 @@ std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
|
||||
if (einfo.nixCode.has_value()) {
|
||||
switch (einfo.nixCode->errPos.origin) {
|
||||
case foFile: {
|
||||
out << fmt("%1%in file: " ANSI_BLUE "%2% %3%" ANSI_NORMAL,
|
||||
prefix,
|
||||
einfo.nixCode->errPos.file,
|
||||
showErrPos(einfo.nixCode->errPos)) << std::endl;
|
||||
out << prefix << std::endl;
|
||||
auto &pos = einfo.nixCode->errPos;
|
||||
out << ANSI_BLUE << "at: " << ANSI_YELLOW << showErrPos(pos) <<
|
||||
ANSI_BLUE << " in file: " << ANSI_NORMAL << pos.file << std::endl;
|
||||
break;
|
||||
}
|
||||
case foString: {
|
||||
out << fmt("%1%from command line argument %2%", prefix, showErrPos(einfo.nixCode->errPos)) << std::endl;
|
||||
out << prefix << std::endl;
|
||||
out << fmt("%1%from command line argument %2%", prefix, showErrPos(einfo.nixCode->errPos)) << std::endl;
|
||||
break;
|
||||
}
|
||||
case foStdin: {
|
||||
out << fmt("%1%from stdin %2%", prefix, showErrPos(einfo.nixCode->errPos)) << std::endl;
|
||||
out << prefix << std::endl;
|
||||
out << fmt("%1%from stdin %2%", prefix, showErrPos(einfo.nixCode->errPos)) << std::endl;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -307,22 +306,6 @@ std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
|
||||
nl = true;
|
||||
}
|
||||
|
||||
// traces
|
||||
for (auto iter = einfo.traces.begin(); iter != einfo.traces.end(); ++iter)
|
||||
{
|
||||
|
||||
try {
|
||||
auto pos = *iter->pos;
|
||||
out << iter->hint.str() << showErrPos(pos) << std::endl;
|
||||
NixCode nc { .errPos = pos };
|
||||
getCodeLines(nc);
|
||||
printCodeLines(out, prefix, nc);
|
||||
} catch(const std::bad_optional_access& e) {
|
||||
out << iter->hint.str() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// description
|
||||
if (einfo.description != "") {
|
||||
if (nl)
|
||||
@ -352,6 +335,26 @@ std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
|
||||
nl = true;
|
||||
}
|
||||
|
||||
// traces
|
||||
for (auto iter = einfo.traces.rbegin(); iter != einfo.traces.rend(); ++iter)
|
||||
{
|
||||
try {
|
||||
auto pos = *iter->pos;
|
||||
if (nl)
|
||||
out << std::endl << prefix;
|
||||
out << std::endl << prefix;
|
||||
out << iter->hint.str() << std::endl;
|
||||
out << ANSI_BLUE << "at: " << ANSI_YELLOW << showErrPos(pos) <<
|
||||
ANSI_BLUE << " in file: " << ANSI_NORMAL << pos.file << std::endl;
|
||||
nl = true;
|
||||
NixCode nc { .errPos = pos };
|
||||
getCodeLines(nc);
|
||||
printCodeLines(out, prefix, nc);
|
||||
} catch(const std::bad_optional_access& e) {
|
||||
out << iter->hint.str() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user