ghedeon
03/21/2019, 7:56 AMDeffered
into another Deferred
with a custom exception? There is no coroutine context in that place, so I can't use .await()
ghedeon
03/21/2019, 9:34 AMval 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())
})