Skip to content

Commit

Permalink
Add descriptive error for port binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ButterscotchV committed Aug 13, 2024
1 parent b1285ec commit 69483dc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions SlimeVrOta/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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...");
Expand Down

0 comments on commit 69483dc

Please sign in to comment.