From c7c91e804f6f1defaa50b5805b488aadfe985312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Sun, 8 Oct 2023 09:32:07 +0800 Subject: [PATCH] fix: safely save for the json files. --- .../Configuration/OtherConfiguration.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/RotationSolver.Basic/Configuration/OtherConfiguration.cs b/RotationSolver.Basic/Configuration/OtherConfiguration.cs index 729716648..29778d7cd 100644 --- a/RotationSolver.Basic/Configuration/OtherConfiguration.cs +++ b/RotationSolver.Basic/Configuration/OtherConfiguration.cs @@ -1,6 +1,4 @@ -using Dalamud.Game.ClientState.GamePad; -using Dalamud.Logging; -using ECommons.DalamudServices; +using ECommons.DalamudServices; namespace RotationSolver.Basic.Configuration; @@ -190,11 +188,18 @@ private static void Save(T value, string name) private static void SavePath(T value, string path) { - File.WriteAllTextAsync(path, - JsonConvert.SerializeObject(value, Formatting.Indented, new JsonSerializerSettings() + try { - TypeNameHandling = TypeNameHandling.None, - })); + File.WriteAllTextAsync(path, + JsonConvert.SerializeObject(value, Formatting.Indented, new JsonSerializerSettings() + { + TypeNameHandling = TypeNameHandling.None, + })); + } + catch(Exception ex) + { + Svc.Log.Warning(ex, $"Failed to save the file to {path}"); + } } private static void InitOne(ref T value, string name, bool download = true) @@ -239,4 +244,4 @@ private static void InitOne(ref T value, string name, bool download = true) } } } -#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member +#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member \ No newline at end of file