Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit c216d74

Browse files
committed
improve hotkey file parsing error handling
1 parent aa7962f commit c216d74

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Interop/HotkeyControl.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Linq;
5+
using System.Threading;
6+
using System.Windows.Forms;
47
using System.Xml;
58
using SPCode.Utils;
69

@@ -96,6 +99,19 @@ public static void CheckAndBufferHotkeys()
9699
});
97100

98101
}
102+
catch (XmlException ex)
103+
{
104+
var invalidHotkeysFile = Constants.HotkeysFile + ".invalid";
105+
if (File.Exists(invalidHotkeysFile))
106+
{
107+
File.Delete(invalidHotkeysFile);
108+
}
109+
File.Move(Constants.HotkeysFile, invalidHotkeysFile);
110+
CreateDefaultHotkeys();
111+
MessageBox.Show("There was an error parsing the Hotkeys.xml file.\n" +
112+
$"It has been renamed to {invalidHotkeysFile}, and a new one was created.\n" +
113+
$"Details: {ex.Message}", "SPCode Error");
114+
}
99115
catch (Exception ex)
100116
{
101117
throw new Exception("Error while checking and buffering the hotkeys", ex);

0 commit comments

Comments
 (0)