include orignal json in worker error message

This commit is contained in:
Jörg Thalheim 2023-12-10 21:18:04 +01:00 committed by mergify[bot]
parent d48cfadb3d
commit e1ad62cef1

View file

@ -129,7 +129,7 @@ void collector(Sync<State> &state_, std::condition_variable &wakeup) {
/* Check whether the existing worker process is still there. */ /* Check whether the existing worker process is still there. */
auto s = fromReader->readLine(); auto s = fromReader->readLine();
if (s == "") { if (s.empty()) {
handleBrokenWorkerPipe(*proc.get()); handleBrokenWorkerPipe(*proc.get());
} else if (s == "restart") { } else if (s == "restart") {
proc_ = std::nullopt; proc_ = std::nullopt;
@ -140,7 +140,8 @@ void collector(Sync<State> &state_, std::condition_variable &wakeup) {
auto json = json::parse(s); auto json = json::parse(s);
throw Error("worker error: %s", (std::string)json["error"]); throw Error("worker error: %s", (std::string)json["error"]);
} catch (const json::exception &e) { } catch (const json::exception &e) {
throw Error("Received invalid JSON from worker: %s '%s'", throw Error(
"Received invalid JSON from worker: %s\n json: '%s'",
e.what(), s); e.what(), s);
} }
} }
@ -174,14 +175,15 @@ void collector(Sync<State> &state_, std::condition_variable &wakeup) {
/* Wait for the response. */ /* Wait for the response. */
auto respString = fromReader->readLine(); auto respString = fromReader->readLine();
if (respString == "") { if (respString.empty()) {
handleBrokenWorkerPipe(*proc.get()); handleBrokenWorkerPipe(*proc.get());
} }
json response; json response;
try { try {
response = json::parse(respString); response = json::parse(respString);
} catch (const json::exception &e) { } catch (const json::exception &e) {
throw Error("Received invalid JSON from worker: %s '%s'", throw Error(
"Received invalid JSON from worker: %s\n json: '%s'",
e.what(), respString); e.what(), respString);
} }