diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-08-21T13·22+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2018-08-21T13·22+0200 |
commit | ebe3d2d3704aca001ff818295af014581dcf348f (patch) | |
tree | 764c095d28a734dd4ba89c94de086214460bbc93 /src/libutil/serialise.hh | |
parent | 6317c65937ad7d9c5a954c4dfc48de259e55f4f3 (diff) |
Improve 'coroutine has finished' error message
Diffstat (limited to 'src/libutil/serialise.hh')
-rw-r--r-- | src/libutil/serialise.hh | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh index 14b62fdb6774..4b6ad5da5b9c 100644 --- a/src/libutil/serialise.hh +++ b/src/libutil/serialise.hh @@ -214,7 +214,11 @@ struct LambdaSource : Source /* Convert a function that feeds data into a Sink into a Source. The Source executes the function as a coroutine. */ -std::unique_ptr<Source> sinkToSource(std::function<void(Sink &)> fun); +std::unique_ptr<Source> sinkToSource( + std::function<void(Sink &)> fun, + std::function<void()> eof = []() { + throw EndOfFile("coroutine has finished"); + }); void writePadding(size_t len, Sink & sink); |