Generalize error message when creating a server fails

This commit is contained in:
Kevin Azzam
2015-09-17 20:03:05 +02:00
parent 89f2a479bf
commit f4461b292e

View File

@@ -119,13 +119,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
Game.CreateServer(settings);
}
catch (System.Net.Sockets.SocketException)
catch (System.Net.Sockets.SocketException e)
{
ConfirmationDialogs.CancelPrompt(
"Server Creation Failed",
"Could not listen on port {0}.\n\nCheck if the port is already being used.".F(Game.Settings.Server.ListenPort),
cancelText: "OK");
var err_msg = "Could not listen on port {0}.".F(Game.Settings.Server.ListenPort);
if (e.ErrorCode == 10048) { // AddressAlreadyInUse (WSAEADDRINUSE)
err_msg += "\n\nCheck if the port is already being used.";
} else {
err_msg += "\n\nError is: \"{0}\" ({1})".F(e.Message, e.ErrorCode);
}
ConfirmationDialogs.CancelPrompt("Server Creation Failed", err_msg, cancelText: "OK");
return;
}