From ab9dddfb7ad1e252e7abd6956765b87a05d298c2 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Tue, 14 Oct 2025 15:31:15 +0200 Subject: [PATCH] libutil: wrap async kj exceptions as errors this is important for rpc error reporting: if the peer disconnects we want to throw a useful error that can e.g. let pending builds finish, not kill the entire process because kj errors are non-lix exceptions. Change-Id: I41ebe10ad7fd65d886238ce52eeca1fa243b1bb2 --- lix/libutil/async.hh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lix/libutil/async.hh b/lix/libutil/async.hh index 4c4e07a6f..a78b241da 100644 --- a/lix/libutil/async.hh +++ b/lix/libutil/async.hh @@ -121,6 +121,11 @@ T runAsyncUnwrap(Result t) } catch (::nix::BaseException & e) { \ e.addAsyncTrace(::std::source_location::current(), _l_ctx()); \ throw; \ + /* NOLINTNEXTLINE(lix-foreign-exceptions) */ \ + } catch (::kj::Exception & e) { \ + ::nix::Error fe{e.getDescription().cStr()}; \ + fe.addAsyncTrace(::std::source_location::current(), _l_ctx()); \ + throw fe; \ } catch (...) { \ auto fe = ::nix::ForeignException::wrapCurrent(); \ fe.addAsyncTrace(::std::source_location::current(), _l_ctx()); \