mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Catch exceptions for bots for onTextReceived
Avoid crashing due to bots not properly processing text
This commit is contained in:
parent
c30d3025f7
commit
aaced855d8
1 changed files with 16 additions and 3 deletions
|
|
@ -305,8 +305,21 @@ namespace MinecraftClient
|
||||||
public void OnTextReceived(string text)
|
public void OnTextReceived(string text)
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted(text, false);
|
ConsoleIO.WriteLineFormatted(text, false);
|
||||||
foreach (ChatBot bot in new List<ChatBot>(bots))
|
for (int i = 0; i < bots.Count; i++)
|
||||||
bot.GetText(text);
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bots[i].GetText(text);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (!(e is ThreadAbortException))
|
||||||
|
{
|
||||||
|
ConsoleIO.WriteLineFormatted("§8GetText: Got error from " + bots[i].ToString() + ": " + e.ToString());
|
||||||
|
}
|
||||||
|
else throw; //ThreadAbortException should not be caught
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -357,7 +370,7 @@ namespace MinecraftClient
|
||||||
{
|
{
|
||||||
if (!(e is ThreadAbortException))
|
if (!(e is ThreadAbortException))
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§8Got error from " + bots[i].ToString() + ": " + e.ToString());
|
ConsoleIO.WriteLineFormatted("§8Update: Got error from " + bots[i].ToString() + ": " + e.ToString());
|
||||||
}
|
}
|
||||||
else throw; //ThreadAbortException should not be caught
|
else throw; //ThreadAbortException should not be caught
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue