Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #114 #117

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.sdk.growthbook.network

import java.net.UnknownHostException
import java.util.concurrent.TimeoutException
import com.sdk.growthbook.utils.Resource
import kotlinx.coroutines.Job
import io.ktor.client.HttpClient
Expand All @@ -15,6 +17,8 @@ import io.ktor.client.request.prepareGet
import io.ktor.client.call.body
import io.ktor.client.statement.HttpStatement
import io.ktor.client.request.headers
import io.ktor.client.plugins.ClientRequestException
import io.ktor.client.plugins.ServerResponseException
import kotlinx.coroutines.flow.callbackFlow
import io.ktor.utils.io.ByteReadChannel
import com.sdk.growthbook.utils.readSse
Expand Down Expand Up @@ -57,11 +61,21 @@ class DefaultGBNetworkDispatcher(
onError: (Throwable) -> Unit
): Job =
CoroutineScope(PlatformDependentIODispatcher).launch {
val result = client.get(request)
try {
onSuccess(result.body())
} catch (ex: Exception) {
onError(ex)
val result = client.get(request)
try {
onSuccess(result.body())
} catch (exception: Exception) {
onError(exception)
}
} catch (exception: UnknownHostException) {
onError(exception)
} catch (exception: ClientRequestException) {
onError(exception)
} catch (exception: ServerResponseException) {
onError(exception)
} catch (exception: TimeoutException) {
onError(exception)
}
}

Expand Down
Loading