From 71f40a7a5a1baf344a7fa7130295b97695dc33cb Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Thu, 21 Nov 2024 18:12:43 +0600 Subject: [PATCH 1/2] refactor: improve exception handling with coroutine cancellation exception --- .../main/java/foundation/e/apps/data/NetworkHandler.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt b/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt index 30c7e0384..f3c67ecf9 100644 --- a/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt +++ b/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt @@ -1,6 +1,5 @@ /* - * Copyright MURENA SAS 2023 - * Apps Quickly and easily install Android apps onto your device! + * Copyright (C) 2024 e Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,13 +13,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * */ package foundation.e.apps.data +import foundation.e.apps.data.login.exceptions.GPlayException import foundation.e.apps.data.playstore.utils.GPlayHttpClient import foundation.e.apps.data.playstore.utils.GplayHttpRequestException -import foundation.e.apps.data.login.exceptions.GPlayException +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.delay import timber.log.Timber import java.net.SocketTimeoutException @@ -37,6 +38,8 @@ private const val INITIAL_DELAY_RETRY_IN_SECONDS = 1 suspend fun handleNetworkResult(call: suspend () -> T): ResultSupreme { return try { ResultSupreme.Success(call()) + } catch (e: CancellationException) { + throw e } catch (e: SocketTimeoutException) { handleSocketTimeoutException(e) } catch (e: GplayHttpRequestException) { -- GitLab From f02a81a73ee1b2a08bd6f9b3eab90a9308ed8437 Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Thu, 21 Nov 2024 19:38:39 +0600 Subject: [PATCH 2/2] refactor: update copyright text --- app/src/main/java/foundation/e/apps/data/NetworkHandler.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt b/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt index f3c67ecf9..6cadc578d 100644 --- a/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt +++ b/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt @@ -1,5 +1,7 @@ /* * Copyright (C) 2024 e Foundation + * Copyright (C) 2023 MURENA SAS + * Apps Quickly and easily install Android apps onto your device! * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- GitLab