From 69483dcc24414464c673bd443a46b05042f33ade Mon Sep 17 00:00:00 2001 From: Butterscotch! Date: Mon, 12 Aug 2024 20:11:43 -0400 Subject: [PATCH] Add descriptive error for port binding --- SlimeVrOta/Program.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/SlimeVrOta/Program.cs b/SlimeVrOta/Program.cs index 1bf891d..fe2b7db 100644 --- a/SlimeVrOta/Program.cs +++ b/SlimeVrOta/Program.cs @@ -23,7 +23,17 @@ SocketType.Dgram, ProtocolType.Udp ); - slimeSocket.Bind(new IPEndPoint(IPAddress.Any, port)); + try + { + slimeSocket.Bind(new IPEndPoint(IPAddress.Any, port)); + } + catch (Exception e) + { + throw new OtaException( + $"Error while binding socket, make sure SlimeVR isn't running and port {port} is not in use!", + e + ); + } var endPoint = new IPEndPoint(IPAddress.Any, port); async Task WaitForHandshake() @@ -74,9 +84,9 @@ await File.ReadAllBytesAsync(file.FullName), EspOta.OtaCommands.FLASH ); } - catch (Exception ex) + catch (Exception e) { - throw new OtaException($"Failed to flash tracker {endPoint}.", ex); + throw new OtaException($"Failed to flash tracker {endPoint}.", e); } Console.WriteLine("Waiting to receive post-flash handshake...");