Skip to content

Commit

Permalink
Attempt to catch UnauthorizedAccessException when reading from stdin …
Browse files Browse the repository at this point in the history
…to avoid constant error log spam when stdin is unreadable

This can happen e.g. if being run in nohup mode
  • Loading branch information
UnknownShadow200 committed May 30, 2024
1 parent 5e89553 commit a3dd5b5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ public static class Program {
} 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
Expand Down

0 comments on commit a3dd5b5

Please sign in to comment.