From 233c4cf30ffa3615259348111f16e16132a50dad Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 21 Mar 2023 22:16:44 +0100 Subject: [PATCH] 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. --- src/libutil/error.cc | 6 +++--- 1 file 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;