Эх сурвалжийг харах

Add coroutineExceptionHandler to UnifiedSearchRemoteRepository

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 жил өмнө
parent
commit
4dd6a6d277

+ 10 - 2
app/src/main/java/com/owncloud/android/ui/unifiedsearch/UnifiedSearchRemoteRepository.kt

@@ -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,