AndreiBogdan
10/08/2024, 10:52 AMactual fun isNetworkError(throwable: Throwable): Boolean {
return (throwable as? NSError)?.domain == NSURLErrorDomain &&
(throwable.code == NSURLErrorNotConnectedToInternet ||
throwable.code == NSURLErrorNetworkConnectionLost)
}
public val Char.code: Int defined in kotlin
e: file:///Users/runner/work/../shared/src/iosMain/kotlin/com/../shared/Platform.kt:93:31 Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
93
public val Char.code: Int defined in kotlin
i'm guessing throwable.code is a Char instead of Int ?! I got the above from chatGPT, i tried to add throwable.code.toInt() but did not work. Got the same error
I'd do it another way entirely, but I have no clue how ...mbonnin
10/08/2024, 11:42 AMmbonnin
10/08/2024, 11:42 AMmbonnin
10/08/2024, 11:43 AMval cause = apolloNetworkException.platformCause
// assertIs doesn't work with Obj-C classes so we rely on `check` instead
// assertIs<NSError>(cause)
check(cause is NSError)
assertEquals(cause.domain, NSURLErrorDomain)
assertEquals(cause.code, NSURLErrorCannotConnectToHost)
mbonnin
10/08/2024, 11:44 AMApolloNetworkException
and then that exception.platformCause
is an instance of NSError
and you shuold be okAndreiBogdan
10/08/2024, 2:34 PMCUCU :: userModel.throwable?.cause :: null
CUCU :: userModel.throwable :: com.apollographql.apollo3.exception.ApolloNetworkException: Failed to execute GraphQL http network request
CUCU :: (throwable as? NSError) :: null
CUCU :: throwable as? NSError)?.domain == NSURLErrorDomain :: false
CUCU :: (throwable as? NSError)?.code :: null
It seems the throwable is an ApolloNetworkException, but tehre's no cause ... it's null. either i'm doing something wrong or ... i have no idea...mbonnin
10/08/2024, 2:40 PMplatformCause
mbonnin
10/08/2024, 2:40 PM