ApolloCompositeException

class ApolloCompositeException(first: Throwable?, second: Throwable?) : ApolloException

Multiple exceptions happened. This happens typically when a CacheFirst request fails to fetch both the cache and the network. In that case, ApolloCompositeException is thrown, and you can access the underlying cache and network exceptions in suppressedExceptions.

suppressedExceptions uses Throwable.suppressedExceptions for convenience, but you can safely cast any suppressedExceptions to an ApolloException.

try {
val response = apolloClient.query(sampleQuery).fetchPolicy(CacheFirst).execute()
} catch (e: ApolloException) {
when (e) {
is ApolloCompositeException -> {
e.suppressedExceptions.forEach { suppressed ->
handleException(suppressed as ApolloException)
}
}
else -> handleException(e)
}
}

// A function that handles all non-composite exceptions
fun handleException(e: ApolloException) {
when (e) {
is CacheMissException -> // There was a cache miss
is ApolloHttpException -> // The response was received with an HTTP error
is ApolloNetworkException -> // The response was not received due to a network exception
else -> // Something else happened (parsing error, ...)
}

Constructors

Link copied to clipboard
fun ApolloCompositeException(first: Throwable?, second: Throwable?)

Properties

Link copied to clipboard
open val cause: Throwable?
Link copied to clipboard
Link copied to clipboard
open val message: String?
Link copied to clipboard