Skip to content

Commit e779852

Browse files
committed
fix: Catch cryptographic exception on server startup and show in GUI
Right now we're crashing on intermittent cryptographic exceptions thrown on CI. This shouldn't crash the GUI, but should be shown in the GUI. Fixes #277
1 parent a035629 commit e779852

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

Buttplug.Apps.WebsocketServerGUI/WebsocketServerControl.xaml.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
using Buttplug.Components.Controls;
2-
using Buttplug.Components.WebsocketServer;
3-
using Buttplug.Core;
4-
using Buttplug.Server;
5-
using JetBrains.Annotations;
6-
using Microsoft.Win32;
7-
using System;
1+
using System;
82
using System.Collections.ObjectModel;
93
using System.Net;
104
using System.Net.NetworkInformation;
115
using System.Net.Sockets;
6+
using System.Security.Cryptography;
127
using System.Timers;
138
using System.Windows;
149
using System.Windows.Controls;
10+
using Buttplug.Components.Controls;
11+
using Buttplug.Components.WebsocketServer;
12+
using Buttplug.Core;
13+
using Buttplug.Server;
14+
using JetBrains.Annotations;
15+
using Microsoft.Win32;
1516
using Windows.UI.Notifications;
1617

1718
namespace Buttplug.Apps.WebsocketServerGUI
@@ -107,6 +108,7 @@ private void WebSocketExceptionHandler(object aObj, [NotNull] UnhandledException
107108
{
108109
errorMessage += "\n\nIf your connection is working, you can ignore this message. Otherwise, this could mean that the client/browser has not accepted our SSL certificate. Try hitting the test button on the \"Websocket Server\" tab.";
109110
}
111+
110112
_currentExceptionMessage = errorMessage;
111113
_log.LogException(aEx.ExceptionObject as Exception, true, errorMessage);
112114
}
@@ -204,8 +206,11 @@ public void StartServer()
204206
}
205207
catch (SocketException e)
206208
{
207-
_log.LogException(e);
208-
MessageBox.Show(e.Message, "Buttplug Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
209+
_log.LogException(e, true, e.Message);
210+
}
211+
catch (CryptographicException e)
212+
{
213+
_log.LogException(e, true, e.Message);
209214
}
210215
}
211216

0 commit comments

Comments
 (0)