aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-06-23 09:36:58 -0600
committerBen Burdette <bburdette@gmail.com>2020-06-23 09:36:58 -0600
commit13e87535ffa195690213ed656e2b61218c6894a3 (patch)
tree1f623cac1775f416c4026aba7c15811f728347b6
parent54e8f550c9d5cc88c1161035d366871bb82d4a0c (diff)
traces to bottom
-rw-r--r--src/libutil/error.cc47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/libutil/error.cc b/src/libutil/error.cc
index 222d9cbef..a0dfdbdbd 100644
--- a/src/libutil/error.cc
+++ b/src/libutil/error.cc
@@ -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;
}
}