aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/error.cc9
-rw-r--r--src/libutil/error.hh3
2 files changed, 9 insertions, 3 deletions
diff --git a/src/libutil/error.cc b/src/libutil/error.cc
index 5f86e1e76..cf4f4a56f 100644
--- a/src/libutil/error.cc
+++ b/src/libutil/error.cc
@@ -9,9 +9,9 @@ namespace nix {
const std::string nativeSystem = SYSTEM;
-void BaseError::addTrace(std::optional<ErrPos> e, hintformat hint)
+void BaseError::addTrace(std::optional<ErrPos> e, hintformat hint, bool frame)
{
- err.traces.push_front(Trace { .pos = e, .hint = hint });
+ err.traces.push_front(Trace { .pos = e, .hint = hint, .frame = frame });
}
// c++ std::exception descendants must have a 'const char* what()' function.
@@ -382,6 +382,7 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s
*
*/
+ bool frameOnly = false;
if (!einfo.traces.empty()) {
unsigned int count = 0;
for (auto iter = einfo.traces.rbegin(); iter != einfo.traces.rend(); ++iter) {
@@ -391,7 +392,11 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s
}
if (iter->hint.str().empty()) continue;
+ if (frameOnly && !iter->frame) continue;
+
count++;
+ frameOnly = iter->frame;
+
oss << "\n" << "… " << iter->hint.str() << "\n";
if (iter->pos.has_value() && (*iter->pos)) {
diff --git a/src/libutil/error.hh b/src/libutil/error.hh
index 50335676e..bf99581e2 100644
--- a/src/libutil/error.hh
+++ b/src/libutil/error.hh
@@ -110,6 +110,7 @@ void printAtPos(const ErrPos & pos, std::ostream & out);
struct Trace {
std::optional<ErrPos> pos;
hintformat hint;
+ bool frame;
};
struct ErrorInfo {
@@ -188,7 +189,7 @@ public:
addTrace(e, hintfmt(std::string(fs), args...));
}
- void addTrace(std::optional<ErrPos> e, hintformat hint);
+ void addTrace(std::optional<ErrPos> e, hintformat hint, bool frame = false);
bool hasTrace() const { return !err.traces.empty(); }
};