https://kotlinlang.org logo
#coroutines
Title
# coroutines
m

myanmarking

01/07/2019, 5:44 PM
Copy code
mainScope.launch {

            try{
                val attr1 = async(<http://dispatchers.IO|dispatchers.IO>) { networkUser.setUserAttrs(userId, mappedServerData.weight).blockingFirst() }catch(){} }
b

bdawg.io

01/07/2019, 6:53 PM
Because an exception isn’t thrown by the
async
function if the provided block throws an exception. You need to wrap your
.await()
call.
Copy code
val attr1Async = async(IO) { ....blockingFirst() }
try {
    attr1Async.await()
} catch (...) {
    ...
}
m

myanmarking

01/07/2019, 6:54 PM
check below, the call is wrapped, that sample is not complete
👍 1
3 Views