Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5dc95c08 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

AM: Catch exceptions during cancellation

parent cac9ab84
Loading
Loading
Loading
Loading
+26 −11
Original line number Diff line number Diff line
@@ -37,8 +37,11 @@ import dagger.assisted.AssistedInject
import foundation.e.accountmanager.AccountTypes
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.runInterruptible
import java.io.IOException
import java.io.InterruptedIOException
import java.util.logging.Level
import java.util.logging.Logger
import kotlin.coroutines.cancellation.CancellationException

/**
 * Refreshes list of home sets and their respective collections of a service type (CardDAV or CalDAV).
@@ -193,18 +196,30 @@ class RefreshCollectionsWorker @AssistedInject constructor(
            )
            return Result.failure()
        } catch (e: Exception) {
            when (e) {
                is CancellationException -> throw e

                is IOException -> {
                    logger.log(Level.WARNING, "I/O issue while refreshing collection list", e)
                    return Result.failure()
                }

                else -> {
                    logger.log(Level.SEVERE, "Couldn't refresh collection list", e)

                    val debugIntent = DebugInfoActivity.IntentBuilder(applicationContext)
                        .withCause(e)
                        .withAccount(account)
                        .build()

                    notifyRefreshError(
                        applicationContext.getString(R.string.refresh_collections_worker_refresh_couldnt_refresh),
                        debugIntent
                    )
                    return Result.failure()
                }
            }
        }

        // update push registrations
        pushRegistrationManager.update(serviceId)