obobo
03/11/2019, 11:12 PMrunBlocking
block. I have a test in which I mock an external service integration throwing an exception. Via runBlocking
I call the suspending function, which in turn creates a new CoroutineScope using CoroutineScope(coroutineContext + <http://Dispatchers.IO|Dispatchers.IO>)
and creates many deferred calls using async
to the mocked external service, then uses awaitAll()
to get their results. Surrounding this code is a try/catch block, which handles the exception. I've stepped in and all of this is working fine.
The problem is when the suspending function returns, the surrounding block declares it exited exceptionally and throws an exception from the runBlocking call. Since I'm handling the exception, what's the right way to prevent the context from picking up the exception?obobo
03/11/2019, 11:26 PMsitepodmatt
03/12/2019, 2:39 AMsitepodmatt
03/12/2019, 2:39 AMsitepodmatt
03/12/2019, 2:40 AM