From 1a1562c46719f24a9a4d779f1e5eccf2ef63c83f Mon Sep 17 00:00:00 2001 From: art0007i Date: Sat, 1 Jul 2023 15:33:24 +0200 Subject: [PATCH] add fallback for config failure --- NeosModLoader/ModConfiguration.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NeosModLoader/ModConfiguration.cs b/NeosModLoader/ModConfiguration.cs index 04badc8..1f8f8da 100644 --- a/NeosModLoader/ModConfiguration.cs +++ b/NeosModLoader/ModConfiguration.cs @@ -492,8 +492,10 @@ private bool AnyValuesSet() catch (Exception e) { // I know not what exceptions the JSON library will throw, but they must be contained - mod.AllowSavingConfiguration = false; - throw new ModConfigurationException($"Error loading config for {mod.NeosMod.Name}", e); + mod.AllowSavingConfiguration = true; + var backupPath = configFile + ".bak"; + Logger.ErrorExternal($"Error loading config for {mod.NeosMod.Name}, creating new config file (old file can be found at {backupPath}). Exception:\n{e}"); + File.Move(configFile, backupPath); } return new ModConfiguration(mod, definition);