Adding exception at used REST port problem

This commit is contained in:
Patrikk 2015-07-06 12:36:48 +01:00
parent 46ab25de58
commit 4f914fc4c9

View file

@ -79,12 +79,20 @@ namespace Rests
public virtual void Start() public virtual void Start()
{ {
if (listener == null) try
{ {
listener = HttpListener.Create(Ip, Port); listener = HttpListener.Create(Ip, Port);
listener.RequestReceived += OnRequest; listener.RequestReceived += OnRequest;
listener.Start(int.MaxValue); listener.Start(int.MaxValue);
} }
catch (Exception ex)
{
TShock.Log.Error("Fatal Startup Exception");
TShock.Log.Error(ex.ToString());
TShock.Log.ConsoleError("Invalid REST configuration: \nYou may already have a REST service bound to port {0}. \nPlease adjust your configuration and restart the server. \nPress any key to exit.", Port);
Console.ReadLine();
Environment.Exit(1);
}
} }
public void Start(IPAddress ip, int port) public void Start(IPAddress ip, int port)