aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/error.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/error.cc')
-rw-r--r--src/libutil/error.cc42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/libutil/error.cc b/src/libutil/error.cc
index 9cac6ac91..449baaad1 100644
--- a/src/libutil/error.cc
+++ b/src/libutil/error.cc
@@ -262,6 +262,28 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s
prefix += ":" ANSI_NORMAL " ";
std::ostringstream oss;
+
+ // traces
+ if (showTrace && !einfo.traces.empty()) {
+ for (auto iter = einfo.traces.begin(); iter != einfo.traces.end(); ++iter) {
+ oss << "\n" << "… " << iter->hint.str() << "\n";
+
+ if (iter->pos.has_value() && (*iter->pos)) {
+ auto pos = iter->pos.value();
+ oss << "\n";
+ printAtPos(pos, oss);
+
+ auto loc = getCodeLines(pos);
+ if (loc.has_value()) {
+ oss << "\n";
+ printCodeLines(oss, "", pos, *loc);
+ oss << "\n";
+ }
+ }
+ }
+ oss << "\n" << prefix;
+ }
+
oss << einfo.msg << "\n";
if (einfo.errPos.has_value() && *einfo.errPos) {
@@ -285,26 +307,6 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s
"?" << std::endl;
}
- // traces
- if (showTrace && !einfo.traces.empty()) {
- for (auto iter = einfo.traces.begin(); iter != einfo.traces.end(); ++iter) {
- oss << "\n" << "… " << iter->hint.str() << "\n";
-
- if (iter->pos.has_value() && (*iter->pos)) {
- auto pos = iter->pos.value();
- oss << "\n";
- printAtPos(pos, oss);
-
- auto loc = getCodeLines(pos);
- if (loc.has_value()) {
- oss << "\n";
- printCodeLines(oss, "", pos, *loc);
- oss << "\n";
- }
- }
- }
- }
-
out << indent(prefix, std::string(filterANSIEscapes(prefix, true).size(), ' '), chomp(oss.str()));
return out;