aboutsummaryrefslogtreecommitdiff
path: root/src/build-remote/build-remote.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-01-25 12:50:57 +0100
committerGitHub <noreply@github.com>2021-01-25 12:50:57 +0100
commit488a826842296c9c2933fb53cc884ed8518f9110 (patch)
tree5ab9dd63a9609ddaec8f5ba136b78ffd6eef734c /src/build-remote/build-remote.cc
parentc5b42c5a42138329c6d02da0d8a53cb59c6077f4 (diff)
parent0eb22db3116585821096b7b81295d4bbf5550343 (diff)
Merge pull request #4467 from edolstra/error-formatting
Improve error formatting
Diffstat (limited to 'src/build-remote/build-remote.cc')
-rw-r--r--src/build-remote/build-remote.cc54
1 files changed, 24 insertions, 30 deletions
diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc
index 68af3e966..17a0a8373 100644
--- a/src/build-remote/build-remote.cc
+++ b/src/build-remote/build-remote.cc
@@ -176,13 +176,14 @@ static int main_build_remote(int argc, char * * argv)
else
{
// build the hint template.
- string hintstring = "derivation: %s\nrequired (system, features): (%s, %s)";
- hintstring += "\n%s available machines:";
- hintstring += "\n(systems, maxjobs, supportedFeatures, mandatoryFeatures)";
+ string errorText =
+ "Failed to find a machine for remote build!\n"
+ "derivation: %s\nrequired (system, features): (%s, %s)";
+ errorText += "\n%s available machines:";
+ errorText += "\n(systems, maxjobs, supportedFeatures, mandatoryFeatures)";
- for (unsigned int i = 0; i < machines.size(); ++i) {
- hintstring += "\n(%s, %s, %s, %s)";
- }
+ for (unsigned int i = 0; i < machines.size(); ++i)
+ errorText += "\n(%s, %s, %s, %s)";
// add the template values.
string drvstr;
@@ -191,25 +192,21 @@ static int main_build_remote(int argc, char * * argv)
else
drvstr = "<unknown>";
- auto hint = hintformat(hintstring);
- hint
- % drvstr
- % neededSystem
- % concatStringsSep<StringSet>(", ", requiredFeatures)
- % machines.size();
-
- for (auto & m : machines) {
- hint % concatStringsSep<vector<string>>(", ", m.systemTypes)
- % m.maxJobs
- % concatStringsSep<StringSet>(", ", m.supportedFeatures)
- % concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
- }
+ auto error = hintformat(errorText);
+ error
+ % drvstr
+ % neededSystem
+ % concatStringsSep<StringSet>(", ", requiredFeatures)
+ % machines.size();
+
+ for (auto & m : machines)
+ error
+ % concatStringsSep<vector<string>>(", ", m.systemTypes)
+ % m.maxJobs
+ % concatStringsSep<StringSet>(", ", m.supportedFeatures)
+ % concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
- logErrorInfo(canBuildLocally ? lvlChatty : lvlWarn, {
- .name = "Remote build",
- .description = "Failed to find a machine for remote build!",
- .hint = hint
- });
+ printMsg(canBuildLocally ? lvlChatty : lvlWarn, error);
std::cerr << "# decline\n";
}
@@ -234,12 +231,9 @@ static int main_build_remote(int argc, char * * argv)
} catch (std::exception & e) {
auto msg = chomp(drainFD(5, false));
- logError({
- .name = "Remote build",
- .hint = hintfmt("cannot build on '%s': %s%s",
- bestMachine->storeUri, e.what(),
- (msg.empty() ? "" : ": " + msg))
- });
+ printError("cannot build on '%s': %s%s",
+ bestMachine->storeUri, e.what(),
+ msg.empty() ? "" : ": " + msg);
bestMachine->enabled = false;
continue;
}