ursus
02/08/2019, 3:54 AMkevinherron
02/08/2019, 4:02 AMkevinherron
02/08/2019, 4:02 AMgildor
02/08/2019, 6:45 AMghedeon
02/08/2019, 7:18 AMursus
02/08/2019, 4:26 PMursus
02/08/2019, 4:26 PMursus
02/08/2019, 4:32 PMursus
02/08/2019, 4:36 PMfun ApiClient.whatever(): Result {
try {
val response = api.whatever()
if (response.code != 200) {
return Result.Success(response.body)
} else {
return Result.Error(BadRequestError(code)
}
} catch(ex: IOException) {
return Result.Error(IOError)
} catch(ex: Exception) {
throw ex
}
}
ghedeon
02/08/2019, 5:09 PMrunCatching{}
because I really like how you can have pure data in your stream in Rx for example, not mixed with errors, and I really hate to wrap it in Result like LiveData does, just because you have no other options. Idk... it's messed up. I clearly remember when everybody was hyped about rx .onError{}
because separate error channel is a step forward from try/catch and now try/catch is being sold as something revolutionary, idiomatic and clean.ursus
02/08/2019, 5:15 PMghedeon
02/08/2019, 5:21 PMResult
pattern, not necessarily kotlin.Result, but in general.ursus
02/08/2019, 5:24 PMursus
02/08/2019, 7:59 PMgildor
02/09/2019, 1:23 AMgildor
02/09/2019, 1:25 AMim still kind of unsure as how to do error handlng, since checked exceptions are gone, yet I need them in java interopBut you have checked exception for Java interop, there is
@Throws
annotation for thatursus
02/09/2019, 3:08 PMgildor
02/10/2019, 6:24 AM