Paul Woitaschek
02/23/2017, 12:58 PMelizarov
02/23/2017, 6:57 PMTry
in Scala (because of "try monad"). I cannot convince myself that it is useful enough to include it (and it is very easy to write if you need it). I will appreciate if you (or @gildor) share some real-life use-cases for such a class.Paul Woitaschek
02/23/2017, 7:06 PMkotlin
async {
try {
val user = userManager.user().await()
try {
val movies = movieManager.getMoviesForAge(user.age)
val firstMovie = movies.first()
} catch(e : IoException){
showNetworkError()
} catch(e : ...){
show...
}
} catch(e: IoException){
showNetworkError()
} catch(e : HttpException){
if(e.code==400) showNotSignedInException()
else showNetworkError()
}
}
elizarov
02/23/2017, 7:56 PMPaul Woitaschek
02/23/2017, 7:59 PMelizarov
02/23/2017, 8:05 PMgildor
02/24/2017, 1:08 AMwhen
block, especially with 3 cases, looks better then try
with two catch
blocks %)
Actually I’m not evangelist of this approach. I’m still not sure what will be more useful in the real app and how good this practice. And it’s the reason why I've implement .await()
that throws exception and .awaitResult()
with Result class.
I’m writing Android sample app that uses coroutines for different async operations to show some examples of usage coroutines in Android and understand for myself how to better use itelizarov
02/24/2017, 8:16 AM