From 48ebca011a754d152defd11b7facf152f92886c8 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Thu, 22 Feb 2024 12:10:28 +0100 Subject: Executor: in case of a failing action also report origin ... if provided. This might help users to find the correct place in their code base causing the action to fail. --- .../execution_engine/executor/executor.hpp | 29 ++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/buildtool/execution_engine/executor/executor.hpp') diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index 454772ff..dd6ada70 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -532,7 +533,7 @@ class ExecutorImpl { logger.Emit(LogLevel::Error, "action returned non-zero exit code {}", response->ExitCode()); - PrintError(logger, action->Command()); + PrintError(logger, action); return false; } } @@ -553,7 +554,7 @@ class ExecutorImpl { } return message; }); - PrintError(logger, action->Command()); + PrintError(logger, action); return false; } @@ -596,11 +597,25 @@ class ExecutorImpl { std::move(build_message)); } - void static PrintError(Logger const& logger, - std::vector const& command) noexcept { - logger.Emit(LogLevel::Error, - "Failed to execute command {}", - nlohmann::json(command).dump()); + void static PrintError( + Logger const& logger, + gsl::not_null const& + action) noexcept { + std::ostringstream msg{}; + msg << "Failed to execute command "; + msg << nlohmann::json(action->Command()).dump(); + auto const& origin_map = Progress::Instance().OriginMap(); + auto origins = origin_map.find(action->Content().Id()); + if (origins != origin_map.end() and !origins->second.empty()) { + msg << "\nrequested by"; + for (auto const& origin : origins->second) { + msg << "\n - "; + msg << origin.first.ToString(); + msg << "#"; + msg << origin.second; + } + } + logger.Emit(LogLevel::Error, "{}", msg.str()); } [[nodiscard]] static inline auto ScaleTime(std::chrono::milliseconds t, -- cgit v1.2.3