Skip to content

Commit 39d3d95

Browse files
committed
refactor(cli): harden diagnostic rule ownership
1 parent 2f0f3d1 commit 39d3d95

10 files changed

Lines changed: 115 additions & 335 deletions

File tree

include/vix/cli/errors/rules/UncaughtExceptionRule.hpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

include/vix/cli/errors/runtime/RuntimeRuleUtils.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ namespace vix::cli::errors::runtime
3636

3737
bool icontains(const std::string &text, const std::string &needle);
3838

39+
bool runtime_technical_details_enabled();
40+
3941
std::string strip_line_comment(const std::string &line);
4042

4143
std::optional<std::vector<std::string>> read_file_lines(

src/errors/ErrorPipeline.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ namespace vix::cli::errors
6666
// Coroutines family (always late, very specific signals)
6767
templateRules_.push_back(vix::cli::errors::template_rules::makeCoroutineReturnTypeRule());
6868
templateRules_.push_back(vix::cli::errors::template_rules::makeMissingCoReturnRule());
69-
templateRules_.push_back(vix::cli::errors::template_rules::makeInvalidAwaitableRule());
7069
templateRules_.push_back(vix::cli::errors::template_rules::makeNoMemberAwaitReadyRule());
7170
templateRules_.push_back(vix::cli::errors::template_rules::makeNoMemberAwaitSuspendRule());
7271
templateRules_.push_back(vix::cli::errors::template_rules::makeNoMemberAwaitResumeRule());
7372
templateRules_.push_back(vix::cli::errors::template_rules::makeInvalidPromiseTypeRule());
73+
templateRules_.push_back(vix::cli::errors::template_rules::makeInvalidAwaitableRule());
7474

7575
// Beginner / syntax / common mistakes
7676
rules_.push_back(makeCoutNotDeclaredRule());

src/errors/rules/UncaughtExceptionRule.cpp

Lines changed: 0 additions & 303 deletions
This file was deleted.

src/errors/runtime/RuntimeRuleUtils.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <vix/cli/errors/ErrorContext.hpp>
1717

1818
#include <cctype>
19+
#include <cstdlib>
1920
#include <filesystem>
2021
#include <fstream>
2122
#include <iostream>
@@ -340,6 +341,27 @@ namespace vix::cli::errors::runtime
340341
return false;
341342
}
342343

344+
bool runtime_technical_details_enabled()
345+
{
346+
const char *level = std::getenv("VIX_LOG_LEVEL");
347+
348+
if (level == nullptr || *level == '\0')
349+
return false;
350+
351+
std::string value(level);
352+
353+
std::transform(
354+
value.begin(),
355+
value.end(),
356+
value.begin(),
357+
[](unsigned char character)
358+
{
359+
return static_cast<char>(std::tolower(character));
360+
});
361+
362+
return value == "debug" || value == "trace";
363+
}
364+
343365
std::string strip_line_comment(const std::string &line)
344366
{
345367
const std::size_t pos = line.find("//");
@@ -560,7 +582,8 @@ namespace vix::cli::errors::runtime
560582
const std::string &log,
561583
std::size_t maxLines)
562584
{
563-
if (log.empty() || maxLines == 0)
585+
if (!runtime_technical_details_enabled() ||
586+
log.empty() || maxLines == 0)
564587
return;
565588

566589
std::istringstream input(log);

0 commit comments

Comments
 (0)