Skip to content

Commit 08631a2

Browse files
committed
Improve compile error handling with ErrorHandler and adjust exit code behavior
1 parent 6331443 commit 08631a2

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/commands/run/detail/DirectScriptRunner.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <vix/cli/commands/helpers/ProcessHelpers.hpp>
1616
#include <vix/cli/commands/helpers/TextHelpers.hpp>
1717
#include <vix/cli/commands/run/RunScriptHelpers.hpp>
18+
#include <vix/cli/ErrorHandler.hpp>
1819
#include <vix/cli/Style.hpp>
1920
#include <vix/utils/Env.hpp>
2021

@@ -480,10 +481,23 @@ namespace vix::commands::RunCommand::detail
480481

481482
if (build.exitCode != 0)
482483
{
483-
if (!build.failureHandled)
484+
if (!build.stdoutText.empty() || !build.stderrText.empty())
485+
{
486+
const std::string compileLog = build.stdoutText + build.stderrText;
487+
const bool handled = vix::cli::ErrorHandler::printBuildErrors(
488+
compileLog,
489+
plan.scriptPath,
490+
"Script compile failed");
491+
492+
if (!handled && !build.printed_live)
493+
handle_runtime_exit_code(build.exitCode, "compile", false);
494+
}
495+
else if (!build.failureHandled && !build.printed_live)
496+
{
484497
handle_runtime_exit_code(build.exitCode, "compile", false);
498+
}
485499

486-
return build.exitCode == 0 ? 1 : build.exitCode;
500+
return -build.exitCode;
487501
}
488502

489503
const std::string meta = make_direct_cache_meta(plan.scriptPath, plan);

0 commit comments

Comments
 (0)