From e1ad62cef18a9f7d977ac93d13136f002f0ba185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 10 Dec 2023 21:18:04 +0100 Subject: [PATCH] include orignal json in worker error message --- src/nix-eval-jobs.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/nix-eval-jobs.cc b/src/nix-eval-jobs.cc index d1dd7a6..fce0aa6 100644 --- a/src/nix-eval-jobs.cc +++ b/src/nix-eval-jobs.cc @@ -129,7 +129,7 @@ void collector(Sync &state_, std::condition_variable &wakeup) { /* Check whether the existing worker process is still there. */ auto s = fromReader->readLine(); - if (s == "") { + if (s.empty()) { handleBrokenWorkerPipe(*proc.get()); } else if (s == "restart") { proc_ = std::nullopt; @@ -140,8 +140,9 @@ void collector(Sync &state_, std::condition_variable &wakeup) { auto json = json::parse(s); throw Error("worker error: %s", (std::string)json["error"]); } catch (const json::exception &e) { - throw Error("Received invalid JSON from worker: %s '%s'", - e.what(), s); + throw Error( + "Received invalid JSON from worker: %s\n json: '%s'", + e.what(), s); } } @@ -174,15 +175,16 @@ void collector(Sync &state_, std::condition_variable &wakeup) { /* Wait for the response. */ auto respString = fromReader->readLine(); - if (respString == "") { + if (respString.empty()) { handleBrokenWorkerPipe(*proc.get()); } json response; try { response = json::parse(respString); } catch (const json::exception &e) { - throw Error("Received invalid JSON from worker: %s '%s'", - e.what(), respString); + throw Error( + "Received invalid JSON from worker: %s\n json: '%s'", + e.what(), respString); } /* Handle the response. */