diff --git a/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt b/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt index dbeb3f392..5bcfe6e52 100644 --- a/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt +++ b/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt @@ -30,6 +30,7 @@ import cloud.mindbox.mobile_sdk.services.BackgroundWorkManager import cloud.mindbox.mobile_sdk.utils.Constants import cloud.mindbox.mobile_sdk.utils.LoggingExceptionHandler import cloud.mindbox.mobile_sdk.utils.MigrationManager +import cloud.mindbox.mobile_sdk.utils.loggingRunCatching import com.jakewharton.threetenabp.AndroidThreeTen import kotlinx.coroutines.* import kotlinx.coroutines.Dispatchers.Default @@ -309,23 +310,23 @@ object Mindbox : MindboxLog { * @param pushService - the instance of [MindboxPushService], which handles push notifications. */ fun updatePushToken(context: Context, token: String, pushService: MindboxPushService) = - MindboxLoggerImpl.runCatching { + loggingRunCatching { initComponents(context) mindboxLogI("updatePushToken token: $token with provider $pushService") if (token.trim().isEmpty()) { mindboxLogW("Token is empty! Skipping update token.") - return@runCatching + return@loggingRunCatching } if (MindboxPreferences.isFirstInitialize) { mindboxLogW("Mindbox init was never called. Skipping update token.") - return@runCatching + return@loggingRunCatching } if (pushService.tag != pushServiceHandler?.notificationProvider) { mindboxLogW("Token provider ${pushService.tag} not matching with selected provider ${pushServiceHandler?.notificationProvider}. Skipping update token.") - return@runCatching + return@loggingRunCatching } mindboxScope.launch { diff --git a/sdk/src/main/java/cloud/mindbox/mobile_sdk/utils/LoggingExceptionHandler.kt b/sdk/src/main/java/cloud/mindbox/mobile_sdk/utils/LoggingExceptionHandler.kt index d3148d4ac..874631172 100644 --- a/sdk/src/main/java/cloud/mindbox/mobile_sdk/utils/LoggingExceptionHandler.kt +++ b/sdk/src/main/java/cloud/mindbox/mobile_sdk/utils/LoggingExceptionHandler.kt @@ -14,4 +14,6 @@ internal object LoggingExceptionHandler: ExceptionHandler() { } } -} \ No newline at end of file +} + +internal fun loggingRunCatching(block: () -> T) = LoggingExceptionHandler.runCatching(block) \ No newline at end of file diff --git a/sdk/src/main/java/cloud/mindbox/mobile_sdk/utils/MigrationManager.kt b/sdk/src/main/java/cloud/mindbox/mobile_sdk/utils/MigrationManager.kt index d47758878..4ca122447 100644 --- a/sdk/src/main/java/cloud/mindbox/mobile_sdk/utils/MigrationManager.kt +++ b/sdk/src/main/java/cloud/mindbox/mobile_sdk/utils/MigrationManager.kt @@ -2,7 +2,6 @@ package cloud.mindbox.mobile_sdk.utils import android.content.Context import cloud.mindbox.mobile_sdk.Mindbox -import cloud.mindbox.mobile_sdk.logger.MindboxLoggerImpl import cloud.mindbox.mobile_sdk.logger.mindboxLogI import cloud.mindbox.mobile_sdk.managers.SharedPreferencesManager import cloud.mindbox.mobile_sdk.repository.MindboxPreferences @@ -15,7 +14,7 @@ internal class MigrationManager(val context: Context) { version282() ).filter { it.isNeeded } .onEach { migration -> - MindboxLoggerImpl.runCatching { + loggingRunCatching { mindboxLogI("Run migration '${migration.description}'") migration.run() }