aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/serialise.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-04-06 22:08:58 +0200
committereldritch horrors <pennae@lix.systems>2024-06-23 11:52:49 +0000
commit39a1e248c9e7adea312c5b7e1743a8e55da63e6c (patch)
treeb49c7911ad537c1fe6731508535eda19d7c1e2c3 /src/libutil/serialise.cc
parentf80d95e36dc08c796863680c9ecc6b8f495825b9 (diff)
libutil: remove sinkToSource eof callback
this is only used in one place, and only to set a nicer error message on EndOfFile. the only caller that actually *catches* this exception should provide an error message in that catch block rather than forcing support for setting error message so deep into the stack. copyStorePath is never called outside of PathSubstitutionGoal anyway, which catches everything. Change-Id: Ifbae8706d781c388737706faf4c8a8b7917ca278
Diffstat (limited to 'src/libutil/serialise.cc')
-rw-r--r--src/libutil/serialise.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc
index 3a8a01f16..80b111f08 100644
--- a/src/libutil/serialise.cc
+++ b/src/libutil/serialise.cc
@@ -266,20 +266,17 @@ std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun)
}
-std::unique_ptr<Source> sinkToSource(
- std::function<void(Sink &)> fun,
- std::function<void()> eof)
+std::unique_ptr<Source> sinkToSource(std::function<void(Sink &)> fun)
{
struct SinkToSource : Source
{
typedef boost::coroutines2::coroutine<std::string> coro_t;
std::function<void(Sink &)> fun;
- std::function<void()> eof;
std::optional<coro_t::pull_type> coro;
- SinkToSource(std::function<void(Sink &)> fun, std::function<void()> eof)
- : fun(fun), eof(eof)
+ SinkToSource(std::function<void(Sink &)> fun)
+ : fun(fun)
{
}
@@ -298,7 +295,9 @@ std::unique_ptr<Source> sinkToSource(
});
}
- if (!*coro) { eof(); abort(); }
+ if (!*coro) {
+ throw EndOfFile("coroutine has finished");
+ }
if (pos == cur.size()) {
if (!cur.empty()) {
@@ -317,7 +316,7 @@ std::unique_ptr<Source> sinkToSource(
}
};
- return std::make_unique<SinkToSource>(fun, eof);
+ return std::make_unique<SinkToSource>(fun);
}