Skip to content

Commit e39558e

Browse files
authored
Update error message when port is not received (#16)
1 parent 595e10d commit e39558e

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

CSharpBot/Bot/Program.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ static void Main(string[] args)
1414
}
1515
catch (Exception e)
1616
{
17-
// If you're trying to run in a debugger, look up the port number used in PythonAgent.py in get_port()
17+
// IDE instructions to add the port argument:
18+
// If you're trying to run in an IDE and have auto-run disabled (e.g. to use the debugger), look up the port
19+
// number used in PythonAgent.py in get_port()
1820

1921
// If you're using Visual Studio:
2022
// Right-click the project, choose Properties, go to the Debug section -- there is a box for
@@ -24,9 +26,23 @@ static void Main(string[] args)
2426
// Click the configuration dropdown to the left of the Run and Debug buttons (top right of the window),
2527
// choose Edit Configurations -- there is a box for "Program arguments", enter the port there.
2628

27-
// Example: 45031
28-
Console.WriteLine("Could not get port from arguments to CSharp bot!");
29-
throw e;
29+
// Example of a port: 45031
30+
31+
32+
var currentColor = Console.ForegroundColor;
33+
Console.ForegroundColor = ConsoleColor.Red;
34+
Console.WriteLine(
35+
"Could not get port from arguments to C# bot!\n" +
36+
"If you're reading this message, it means that the C# bot did not receive a valid port in the command line " +
37+
"arguments.\n" +
38+
"If you have configured auto-run, the port should be given to the bot automatically. Otherwise, you'll " +
39+
"need to run the bot with the port every time (e.g. Bot.exe 45031). Note that this port should match the " +
40+
"one in PythonAgent/PythonAgent.py.\n" +
41+
"If you're trying to run the bot without auto-run in an IDE, see this source file " +
42+
"(CSharpBot/Bot/Program.cs) for IDE instructions."
43+
);
44+
Console.ForegroundColor = currentColor;
45+
throw;
3046
}
3147

3248
RLBotDotNet.BotManager<Bot> botManager = new RLBotDotNet.BotManager<Bot>(0);

0 commit comments

Comments
 (0)