How to wrap `Deffered` into another `Deferred` wit...
# coroutines
g
How to wrap
Deffered
into another
Deferred
with a custom exception? There is no coroutine context in that place, so I can't use
.await()
Ok, seems like this is working:
Copy code
val wrapper = CompletableDeferred<RESPONSE>()
val source: CompletableDeferred<RESPONSE> = ...
source.invokeOnCompletion(handler = {
    val ex = source.getCompletionExceptionOrNull()
    if (ex != null) wrapper.completeExceptionally(ex.wrap())
    else wrapper.complete(source.getCompleted())
})