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
This commit is contained in:
eldritch horrors
2025-10-17 11:33:00 +00:00
parent 21d7cb8e1c
commit ab9dddfb7a
+5
View File
@@ -121,6 +121,11 @@ T runAsyncUnwrap(Result<T> 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()); \