Skip to content

Commit 11724c6

Browse files
committed
add try catch cancel call api
1 parent 2fa7940 commit 11724c6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

android/src/main/java/com/formbricks/android/network/FormbricksApiService.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ import kotlinx.serialization.json.decodeFromJsonElement
1313
import kotlinx.serialization.json.jsonObject
1414
import retrofit2.Call
1515
import retrofit2.Retrofit
16+
import java.util.concurrent.CopyOnWriteArrayList
1617

1718
open class FormbricksApiService {
1819

1920
private var retrofit: Retrofit? = null
20-
private val callProvider = mutableListOf<Call<*>>()
21+
private val callProvider = CopyOnWriteArrayList<Call<*>>()
2122
fun initialize(appUrl: String, isLoggingEnabled: Boolean) {
2223
val builder = FormbricksRetrofitBuilder(appUrl, isLoggingEnabled).getBuilder()
2324
if (builder != null) {
@@ -80,7 +81,11 @@ open class FormbricksApiService {
8081
}
8182

8283
fun cancelCallApi() {
83-
callProvider.map { it.cancel() }
84-
callProvider.clear()
84+
try {
85+
callProvider.map { it.cancel() }
86+
callProvider.clear()
87+
} catch (e: Exception) {
88+
Logger.d(e.message ?: "")
89+
}
8590
}
8691
}

0 commit comments

Comments
 (0)