jw
03/04/2020, 6:06 PMnull
and having it take the default value which does not seem like something we want to encourageColton Idle
03/04/2020, 6:15 PMBrendan Weinstein
03/10/2020, 2:41 AMUnknownHostException
. I tried to find a clean way to gracefully handle this without ending up with overly nested try-catch logic. What I ended up doing was defining a `CoroutineExceptionHandler`:
val handler = CoroutineExceptionHandler { coroutineContext, throwable ->
if (throwable is UnknownHostException) {
_state.value = _state.value!!.copy(type = StateType.NO_NETWORK)
} else {
throw throwable
}
}
fun onButtonTap() {
viewModelScope.launch {
val response = getSomethingFromNetwork()
if (response.isSuccessful) {
_state.value = _state.copy(SUCCESS_FETCHING_SOMETHING)
}
_state.value = _state.copy(ERROR_FETCHING_SOMETHING)
}
}
Just curious to get folks' feedback to how to best handle an UnknownHostException when defining a network call with suspend functions and retrofit. I am also curious why this exception is thrown as opposed to returning a specific error type. Is it just a remnant from designing libraries for java-land? Or is it still idiomatic to throw an UnknownHostException as a kotlin library?jw
03/10/2020, 2:42 AMPaul Woitaschek
03/10/2020, 7:23 AMBrendan Weinstein
03/10/2020, 9:36 PMPaul Woitaschek
03/10/2020, 10:40 PMjw
03/10/2020, 10:43 PMjw
03/10/2020, 10:44 PMcoletz
03/12/2020, 11:33 PMColton Idle
03/13/2020, 2:59 AMJake Wharton [JW] [11:22 AM] Btw we built literally what you asked for once: https://github.com/square/dagger-intellij-pluginDoes anyone use this plugin in AS 4.0? I just installed it and I unfortunately don't see the little daggers in my gutter.
Colton Idle
03/17/2020, 3:26 PMRay Ryan
03/20/2020, 7:38 PMghedeon
03/31/2020, 7:52 PMJson {
serialModule = serializersModuleOf(
mapOf(Foo::class to FooSerializer)
)
}.parse(json)
2. Can't locate argument-less serializer for class Foo.
Retrofit.Builder()
.addConverterFactory(Json{ <same configuration> }.asConverterFactory("application/json".toMediaType()))
...
UPD. Seems like it's not supported yet, reported: https://github.com/JakeWharton/retrofit2-kotlinx-serialization-converter/issues/18myanmarking
04/04/2020, 1:34 PMmyanmarking
04/04/2020, 1:35 PMColton Idle
04/04/2020, 4:38 PMmyanmarking
04/04/2020, 5:57 PMmyanmarking
04/04/2020, 5:58 PMalec
04/04/2020, 6:00 PMmyanmarking
04/04/2020, 6:00 PMmyanmarking
04/04/2020, 6:01 PMmyanmarking
04/04/2020, 6:01 PMalec
04/04/2020, 6:01 PMmyanmarking
04/04/2020, 6:01 PMmyanmarking
04/04/2020, 6:01 PMsqldelight {
Database {
schemaOutputDirectory = file("src/main/sqldelight-schemas")
}
}
myanmarking
04/04/2020, 6:01 PMalec
04/04/2020, 6:03 PMmigrate
method does it get called? https://cashapp.github.io/sqldelight/1.x/runtime/com.squareup.sqldelight.db/-sql-driver/-schema/alec
04/04/2020, 6:03 PMmyanmarking
04/04/2020, 6:03 PM