diff --git a/normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/CacheMissLoggingInterceptor.kt b/normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/CacheMissLoggingInterceptor.kt index 7e26207f..ec22acf0 100644 --- a/normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/CacheMissLoggingInterceptor.kt +++ b/normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/CacheMissLoggingInterceptor.kt @@ -12,9 +12,12 @@ import kotlinx.coroutines.flow.onEach class CacheMissLoggingInterceptor(private val log: (String) -> Unit) : ApolloInterceptor { override fun intercept(request: ApolloRequest, chain: ApolloInterceptorChain): Flow> { return chain.proceed(request).onEach { - it.errors.orEmpty().mapNotNull { it.extensions?.get("exception") as? CacheMissException }.forEach { - log(it.message.toString()) - } + if (it.exception is CacheMissException) { + log(it.exception!!.message.toString()) + } else + it.errors.orEmpty().mapNotNull { it.extensions?.get("exception") as? CacheMissException }.forEach { + log(it.message.toString()) + } } } } diff --git a/normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/FetchPolicyInterceptors.kt b/normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/FetchPolicyInterceptors.kt index ad7dff93..be611a30 100644 --- a/normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/FetchPolicyInterceptors.kt +++ b/normalized-cache-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/FetchPolicyInterceptors.kt @@ -140,6 +140,7 @@ private fun ApolloResponse.cacheMissAsException(): Apoll newBuilder() .exception(cacheMissException) .data(null) + .errors(null) .build() } }