Attempt to catch UnauthorizedAccessException when reading from stdin to avoid constant error log spam when stdin is unreadable

This can happen e.g. if being run in nohup mode
This commit is contained in:
UnknownShadow200 2024-05-31 09:43:41 +10:00
parent 5e89553ad4
commit a3dd5b5166

View File

@ -199,6 +199,12 @@ namespace MCGalaxy.Cli {
} else {
UIHelpers.HandleChat(msg);
}
} catch (UnauthorizedAccessException) {
// UnauthorizedAccessException can get thrown when stdin is unreadable
// See https://github.com/dotnet/runtime/issues/21913 for instance
Write("&e** Access denied to stdin, console no longer accepts input **");
Write("&e** If nohup is being used, remove that to avoid this issue **");
break;
} catch (Exception ex) {
// ArgumentException is raised on Mono when you:
// 1) Type a message into a large CLI window