Add coroutineExceptionHandler to UnifiedSearchRemoteRepository

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-06-07 12:18:08 +02:00
parent 2e0d455905
commit 4dd6a6d277
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF

View file

@ -13,6 +13,7 @@ import com.nextcloud.client.network.ClientFactory
import com.nextcloud.common.NextcloudClient
import com.owncloud.android.lib.common.SearchProviders
import com.owncloud.android.lib.common.utils.Log_OC
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -24,12 +25,19 @@ class UnifiedSearchRemoteRepository(
) : IUnifiedSearchRepository {
private var providers: SearchProviders? = null
private val tag = "UnifiedSearchRemoteRepository"
private fun runAsyncWithNcClient(callback: (client: NextcloudClient) -> Unit) =
CoroutineScope(Dispatchers.IO).launch {
private fun runAsyncWithNcClient(callback: (client: NextcloudClient) -> Unit) {
val coroutineExceptionHandler = CoroutineExceptionHandler { _, exception ->
Log_OC.d(tag,"CoroutineExceptionHandler got at runAsyncWithNcClient $exception")
}
CoroutineScope(Dispatchers.IO).launch(coroutineExceptionHandler) {
val client = clientFactory.createNextcloudClient(currentAccountProvider.user)
callback(client)
}
}
override fun queryAll(
query: String,