aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/error.cc
diff options
context:
space:
mode:
authorGuillaume Maudoux <guillaume.maudoux@tweag.io>2022-10-17 03:05:02 +0200
committerGuillaume Maudoux <guillaume.maudoux@tweag.io>2022-10-17 03:05:02 +0200
commitb945b844a9ce8479872f6280aedde27e2974b7f3 (patch)
treee5ba8895aeee956f80c5a79d59d8506f2885005b /src/libutil/error.cc
parent3f9f6ae12712b366c038f21de99c8ede6c805be9 (diff)
Initial frames support
Diffstat (limited to 'src/libutil/error.cc')
-rw-r--r--src/libutil/error.cc9
1 files changed, 7 insertions, 2 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)) {