Pablichjenkov
08/06/2019, 7:59 PMsuspend fun doSomethingAndThrow() { throw(MyException()) }
val coroutineScope = CoroutineScope(Job())
coroutineScope.launch {
try { doSomethingAndThrow() } catch(exception: Exception) { Log.d("MyException got caught") }
}
Is the exception thrown in the suspended fun doSomethingAndThrow(…) caught by my try/catch block or it gets caught through the CoroutineScope hierarchy.
What would be a good practice to catch this exception?louiscad
08/06/2019, 8:01 PMMyException
in the catch
block, as it would do with non suspending code.Pablichjenkov
08/06/2019, 8:04 PMstreetsofboston
08/06/2019, 10:06 PMPablichjenkov
08/06/2019, 10:09 PMPablichjenkov
08/07/2019, 3:51 AM