daemon: complain much louder about unknown std::exception instances falling out

This made debugging https://git.lix.systems/lix-project/lix/issues/681 a
pain in the neck. This is partially a fix, in a certain sense, for
https://git.lix.systems/lix-project/lix/issues/379, but that one also
addresses expected exceptions from the daemon.

Another instance of this error generation site being shit recently:
https://git.lix.systems/lix-project/lix/issues/638

I don't know how we should improve that particular site but we
definitely should complain about uncaught std exceptions with type ids.

Change-Id: I68798300448ee9ebae65c6469ba69e3f933b2895
This commit is contained in:
Jade Lovelace
2025-02-17 14:42:35 -08:00
parent c68457a906
commit 8a5d1c45d2
+8 -1
View File
@@ -15,6 +15,7 @@
#include "lix/libutil/strings.hh"
#include "lix/libutil/args.hh"
#include <boost/core/demangle.hpp>
#include <sstream>
namespace nix::daemon {
@@ -1100,9 +1101,15 @@ void processConnection(
to.flush();
return;
} catch (std::exception & e) {
auto ex = Error(e.what());
auto ex = Error(
"Unexpected exception on the Lix daemon; this is a bug in Lix.\nWe would appreciate a report of the circumstances it happened in at https://git.lix.systems/lix-project/lix.\n%s: %s",
Uncolored(boost::core::demangle(typeid(e).name())),
e.what()
);
tunnelLogger->stopWork(&ex);
to.flush();
// Crash for good measure, so something winds up in system logs and a core dump is generated as well.
std::terminate();
return;
}
}