1616#include < vix/cli/errors/ClangGccParser.hpp>
1717#include < vix/cli/errors/CodeFrame.hpp>
1818#include < vix/cli/errors/CompilerError.hpp>
19+ #include < vix/cli/errors/CompilerDiagnosticPresentation.hpp>
1920#include < vix/cli/errors/ErrorContext.hpp>
2021#include < vix/cli/errors/ErrorPipeline.hpp>
2122#include < vix/cli/errors/RawLogDetectors.hpp>
@@ -259,6 +260,19 @@ namespace vix::cli
259260 const std::string &buildLog,
260261 const fs::path &sourceFile,
261262 const std::string &contextMessage)
263+ {
264+ return printBuildErrors (
265+ buildLog,
266+ sourceFile,
267+ contextMessage,
268+ false );
269+ }
270+
271+ bool ErrorHandler::printBuildErrors (
272+ const std::string &buildLog,
273+ const fs::path &sourceFile,
274+ const std::string &contextMessage,
275+ bool verbose)
262276 {
263277 using namespace vix ::cli::errors;
264278
@@ -333,7 +347,10 @@ namespace vix::cli
333347 ErrorContext ctx{sourceFile, contextMessage, buildLog};
334348 ErrorPipeline pipeline;
335349
336- if (pipeline.tryHandle (errors, ctx))
350+ // Focused rules are intentionally concise. For a diagnostic batch they
351+ // can select a secondary cascading error; render the first parsed error
352+ // instead. Verbose mode always renders the complete parsed set.
353+ if (!verbose && errors.size () == 1 && pipeline.tryHandle (errors, ctx))
337354 return true ;
338355
339356 std::vector<CompilerError> unique;
@@ -374,15 +391,8 @@ namespace vix::cli
374391 return false ;
375392 }
376393
377- /*
378- * Show the first compiler error by default.
379- *
380- * Compiler errors frequently cascade: once the parser cannot
381- * understand one declaration, it may report several secondary
382- * errors. Showing the first error keeps the output focused for
383- * beginners.
384- */
385- const std::size_t maxToShow = 1 ;
394+ const CompilerDiagnosticPresentation presentation =
395+ compiler_diagnostic_presentation (unique.size (), verbose);
386396
387397 CodeFrameOptions codeFrameOptions;
388398 codeFrameOptions.contextLines = 1 ;
@@ -391,7 +401,7 @@ namespace vix::cli
391401 codeFrameOptions.leadingBlankLine = false ;
392402
393403 for (std::size_t i = 0 ;
394- i < unique. size () && i < maxToShow ;
404+ i < presentation. shown ;
395405 ++i)
396406 {
397407 const CompilerError &err = unique[i];
@@ -420,17 +430,12 @@ namespace vix::cli
420430 print_hint (hint);
421431 }
422432
423- const std::size_t hiddenCount =
424- unique.size () > maxToShow
425- ? unique.size () - maxToShow
426- : 0 ;
427-
428- if (hiddenCount > 0 )
433+ if (presentation.show_verbose_hint ())
429434 {
430435 std::cerr << MUTED
431- << hiddenCount
436+ << presentation. hidden
432437 << " more compiler error"
433- << (hiddenCount == 1 ? " " : " s" )
438+ << (presentation. hidden == 1 ? " " : " s" )
434439 << " hidden. Run with --verbose to see them."
435440 << RESET
436441 << " \n " ;
0 commit comments