From 159d5e31d77543b622aa2681083ddd0ced7e5db3 Mon Sep 17 00:00:00 2001 From: Cuong-Tran Date: Wed, 26 Jun 2024 23:52:03 +0700 Subject: [PATCH] refactor: Improve error message handling in GoogleDriveSyncService --- .../tachiyomi/data/sync/service/GoogleDriveSyncService.kt | 4 ++-- config/detekt/baseline.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/sync/service/GoogleDriveSyncService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/sync/service/GoogleDriveSyncService.kt index 8756502f1..4321cce8d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/sync/service/GoogleDriveSyncService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/sync/service/GoogleDriveSyncService.kt @@ -154,11 +154,11 @@ class GoogleDriveSyncService(context: Context, json: Json, syncPreferences: Sync if (retries >= maxRetries) { logcat(LogPriority.ERROR) { "Max retries reached, exiting sync process" } - throw Exception(context.stringResource(SYMR.strings.error_before_sync_gdrive) + ": Max retries reached.") + throw Exception(context.stringResource(SYMR.strings.error_before_sync_gdrive, "Max retries reached.")) } } catch (e: Exception) { logcat(LogPriority.ERROR, throwable = e) { "Error in GoogleDrive beforeSync" } - throw Exception(context.stringResource(SYMR.strings.error_before_sync_gdrive) + ": ${e.message}", e) + throw Exception(context.stringResource(SYMR.strings.error_before_sync_gdrive, e.message ?: "Exception"), e) } } diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml index 625206038..1ff07b8ca 100644 --- a/config/detekt/baseline.xml +++ b/config/detekt/baseline.xml @@ -1962,8 +1962,8 @@ TooGenericExceptionThrown:EHentai.kt$EHentai$throw Exception(it.text()) TooGenericExceptionThrown:ExtensionLoader.kt$ExtensionLoader$throw Exception("Unknown source class type: ${obj.javaClass}") TooGenericExceptionThrown:GoogleDriveSyncService.kt$GoogleDriveService$throw Exception(context.stringResource(MR.strings.google_drive_not_signed_in)) - TooGenericExceptionThrown:GoogleDriveSyncService.kt$GoogleDriveSyncService$throw Exception(context.stringResource(MR.strings.error_before_sync_gdrive) + ": ${e.message}", e) - TooGenericExceptionThrown:GoogleDriveSyncService.kt$GoogleDriveSyncService$throw Exception(context.stringResource(MR.strings.error_before_sync_gdrive) + ": Max retries reached.") + TooGenericExceptionThrown:GoogleDriveSyncService.kt$GoogleDriveSyncService$throw Exception(context.stringResource(MR.strings.error_before_sync_gdrive, e.message ?: "Exception"), e) + TooGenericExceptionThrown:GoogleDriveSyncService.kt$GoogleDriveSyncService$throw Exception(context.stringResource(MR.strings.error_before_sync_gdrive, "Max retries reached.")) TooGenericExceptionThrown:GoogleDriveSyncService.kt$GoogleDriveSyncService$throw Exception(context.stringResource(MR.strings.error_deleting_google_drive_lock_file), e) TooGenericExceptionThrown:GoogleDriveSyncService.kt$GoogleDriveSyncService$throw Exception(context.stringResource(MR.strings.error_uploading_sync_data) + ": ${e.message}", e) TooGenericExceptionThrown:GoogleDriveSyncService.kt$GoogleDriveSyncService$throw Exception(context.stringResource(MR.strings.google_drive_not_signed_in))