From 724ac56c629d92b1dad83df3b8d11ecd0d43acfb Mon Sep 17 00:00:00 2001 From: alexban011 Date: Fri, 1 Jul 2022 09:33:16 +0300 Subject: [PATCH] Exception handleing when loading mod options (#7279) * try catches * catching specific exceptions * try catch when calling the function * removed unused import --- .../unciv/ui/pickerscreens/ModManagementScreen.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt index 2f787546af..cce129e2ed 100644 --- a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt @@ -10,6 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.badlogic.gdx.utils.Align +import com.badlogic.gdx.utils.SerializationException import com.unciv.MainMenuScreen import com.unciv.json.fromJsonFile import com.unciv.json.json @@ -41,6 +42,7 @@ import com.unciv.ui.utils.extensions.onClick import com.unciv.ui.utils.extensions.toCheckBox import com.unciv.ui.utils.extensions.toLabel import com.unciv.ui.utils.extensions.toTextButton +import com.unciv.utils.Log import com.unciv.utils.concurrency.Concurrency import com.unciv.utils.concurrency.launchOnGLThread import kotlinx.coroutines.Job @@ -258,7 +260,15 @@ class ModManagementScreen( } if (installedMod.modOptions.author.isEmpty()) { - Github.rewriteModOptions(repo, installedMod.folderLocation!!) + try { + Github.rewriteModOptions(repo, installedMod.folderLocation!!) + } catch (ex: SerializationException) { + Log.error("Error while adding mod info from repo search:", ex) + return + } catch (ex: Exception) { + Log.error("Error while adding mod info from repo search:", ex) + return + } installedMod.modOptions.author = repo.owner.login installedMod.modOptions.modSize = repo.size }