Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

add fallback for config failure #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions NeosModLoader/ModConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down