diff options
author | Robert Hensing <robert@roberthensing.nl> | 2023-03-21 22:16:44 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2023-03-23 17:29:06 +0100 |
commit | 233c4cf30ffa3615259348111f16e16132a50dad (patch) | |
tree | cf22d2c635c170c6cbd5e292c266092baf793252 | |
parent | 4dcc0a1b766be6242ad5b478b88fd59d5081446f (diff) |
error.cc: Only suggest show-trace when truncated trace items would be printed
Otherwise, a trace consisting of
frame
frame
frame
non-frame
... would reach the non-frame and print the suggestion, even though
it would have ignored the non-frame anyway.
This resulted in a peculariar situation where --show-trace would have
no apparent effect, as the trace was actually already complete.
-rw-r--r-- | src/libutil/error.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libutil/error.cc b/src/libutil/error.cc index e4f0d4677..c9d61942a 100644 --- a/src/libutil/error.cc +++ b/src/libutil/error.cc @@ -302,14 +302,14 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s if (!einfo.traces.empty()) { size_t count = 0; for (const auto & trace : einfo.traces) { + if (trace.hint.str().empty()) continue; + if (frameOnly && !trace.frame) continue; + if (!showTrace && count > 3) { oss << "\n" << ANSI_WARNING "(stack trace truncated; use '--show-trace' to show the full trace)" ANSI_NORMAL << "\n"; break; } - if (trace.hint.str().empty()) continue; - if (frameOnly && !trace.frame) continue; - count++; frameOnly = trace.frame; |