Add try-catch to preven the game from crashing
This commit is contained in:
parent
8d9e568cac
commit
691accdeea
1 changed files with 12 additions and 5 deletions
|
@ -29,6 +29,8 @@ namespace TBConsole
|
||||||
_listener.Prefixes.Add("http://localhost:8019/");
|
_listener.Prefixes.Add("http://localhost:8019/");
|
||||||
_listener.Start();
|
_listener.Start();
|
||||||
while (_running)
|
while (_running)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var context = await _listener.GetContextAsync();
|
var context = await _listener.GetContextAsync();
|
||||||
string resp = await _receiver(await new StreamReader(context.Request.InputStream).ReadToEndAsync());
|
string resp = await _receiver(await new StreamReader(context.Request.InputStream).ReadToEndAsync());
|
||||||
|
@ -36,6 +38,11 @@ namespace TBConsole
|
||||||
await sw.WriteLineAsync(resp);
|
await sw.WriteLineAsync(resp);
|
||||||
sw.Close();
|
sw.Close();
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue