Hmmm - to have to have an explicit channel.close() seems un-groovy
anyway... - would making the async channel-aware make sense, i.e.
instead of:
final channel = AsyncChannel.create()
async {
for (int i = 1; i <= 3; i++) {
someCall()
channel.send(i * i)
}
channel.close()
}
support:
final channel = AsyncChannel.create()
async(channel) {
for (int i = 1; i <= 3; i++) {
someCall()
channel.send(i * i)
}
} // propagates exceptions to channel / closes channel
or maybe even something along the lines of:
final channel = channel {
for (int i = 1; i <= 3; i++) {
someCall()
it.send(i * i)
}
}
?
Am 29.10.2026 um 18:38 schrieb Jochen Theodorou via dev:
On 10/29/26 16:34, MG wrote:
Hi blackdrag*,
would something like the following work, assuming an exception inside
the async block would be wrapped in an AsyncWrapperException by Groovy:
for await (value in channel) try {
println value
}
catch(AsyncWrapperException ae) {
...
}
catch(Throwable t) {
...
}
That works if getting the value throws the exception, which is
actually the case. The problem is that channel does not know about the
exception in the async block, unless you tell the channel. But that
would make the example look ugly and it would still work, till there
is an exception.
bye Jochen