Skip to content

Commit

Permalink
Do not crash the API if config fails to save
Browse files Browse the repository at this point in the history
  • Loading branch information
RainOrigami committed Oct 2, 2023
1 parent d8c9086 commit 9175734
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions BattleBitAPIRunner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,17 @@ private void ModuleConfiguration_OnSavingRequest(object? sender, BattleBitModule
return; // nothing to save
}

File.WriteAllText(filePath, JsonSerializer.Serialize(configurationValue, configurationValue.GetType(), new JsonSerializerOptions()
try
{
WriteIndented = true
}));
File.WriteAllText(filePath, JsonSerializer.Serialize(configurationValue, configurationValue.GetType(), new JsonSerializerOptions()
{
WriteIndented = true
}));
}
catch (Exception ex)
{
this.logger.Error($"Failed to save configuration {property.Name} for module {module.GetType().Name}.", ex);
}
}

private void ModuleConfiguration_OnLoadingRequest(object? sender, BattleBitModule module, PropertyInfo property, string serverName)
Expand Down

0 comments on commit 9175734

Please sign in to comment.