From 107d60027fa22c3b919cce3e8565affbbd8aed3b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 22 Feb 2021 16:29:07 +0100 Subject: [PATCH] hydra-eval-jobs: Fix unexpected EOF when a top-level attr fails --- src/hydra-eval-jobs/hydra-eval-jobs.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/hydra-eval-jobs/hydra-eval-jobs.cc b/src/hydra-eval-jobs/hydra-eval-jobs.cc index 1cea8390..934bf42e 100644 --- a/src/hydra-eval-jobs/hydra-eval-jobs.cc +++ b/src/hydra-eval-jobs/hydra-eval-jobs.cc @@ -235,12 +235,13 @@ static void worker( else throw TypeError("attribute '%s' is %s, which is not supported", attrPath, showType(*v)); } catch (EvalError & e) { + auto msg = e.msg(); // Transmits the error we got from the previous evaluation // in the JSON output. - reply["error"] = filterANSIEscapes(e.msg(), true); + reply["error"] = filterANSIEscapes(msg, true); // Don't forget to print it into the STDERR log, this is // what's shown in the Hydra UI. - printError("error: %s", reply["error"]); + printError(msg); } writeLine(to.get(), reply.dump()); @@ -326,13 +327,15 @@ int main(int argc, char * * argv) EvalState state(myArgs.searchPath, openStore()); Bindings & autoArgs = *myArgs.getAutoArgs(state); worker(state, autoArgs, *to, *from); - } catch (std::exception & e) { + } catch (Error & e) { nlohmann::json err; - err["error"] = e.what(); + auto msg = e.msg(); + err["error"] = filterANSIEscapes(msg, true); + printError(msg); writeLine(to->get(), err.dump()); // Don't forget to print it into the STDERR log, this is // what's shown in the Hydra UI. - printError("error: %s", err["error"]); + writeLine(to->get(), "restart"); } }, ProcessOptions { .allowVfork = false });