egametang/ET · error · Exception
CreateRobotArgs error!
Error message
CreateRobotArgs error!
What it means
CreateRobotConsoleHandler parses console input via CommandLineParser (Parser.Default.ParseArguments<CreateRobotArgs>). WithNotParsed throws a generic 'CreateRobotArgs error!' for any parse failure, discarding the actual errors. The case ConsoleMode.CreateRobot with no args is handled separately (just logs).
Source
Thrown at Packages/cn.etetet.robot/Scripts/Hotfix/Server/CreateRobotConsoleHandler.cs:25
public class CreateRobotConsoleHandler: IConsoleHandler
{
public async ETTask Run(Fiber fiber, ModeContex contex, string content)
{
EntityRef<ModeContex> contexRef = contex;
try
{
switch (content)
{
case ConsoleMode.CreateRobot:
{
Log.Console("CreateRobot args error!");
break;
}
default:
{
CreateRobotArgs options = null;
Parser.Default.ParseArguments<CreateRobotArgs>(content.Split(' '))
.WithNotParsed(error => throw new Exception($"CreateRobotArgs error!"))
.WithParsed(o => { options = o; });
RobotManagerComponent robotManagerComponent = fiber.Root.GetComponent<RobotManagerComponent>();
EntityRef<RobotManagerComponent> robotManagerComponentRef = robotManagerComponent;
// 创建机器人
for (int i = 0; i < options.Num; ++i)
{
robotManagerComponent = robotManagerComponentRef;
await robotManagerComponent.NewRobot(options.SchedulerType, $"Robot_{i}");
Log.Console($"Create Robot_{i}");
}
break;
}
}
}
finallyView on GitHub (pinned to 5cab01f7a8)
Solutions
- Run 'CreateRobot' with no args first to see the help/usage (the WithNotParsed path is bypassed).
- Check CreateRobotArgs field definitions to learn the exact flags and types expected.
- Pass arguments in the documented format (e.g. 'CreateRobot --num 10 --scheduler Default').
- Improve the handler: include the actual parse errors in the exception message instead of a generic string.
Example fix
// before: discards parse errors
.WithNotParsed(error => throw new Exception($"CreateRobotArgs error!"))
// after: surface the real errors
.WithNotParsed(error => throw new Exception($"CreateRobotArgs error: {string.Join(", ", error)}")) Defensive patterns
Strategy: try-catch
Validate before calling
// Validate args shape before invoking the console command
if (string.IsNullOrWhiteSpace(content) || !content.StartsWith("--")) {
Log.Console("Usage: CreateRobot --num <int> [--scheduler <type>]");
return;
} Try / catch
try { /* parse + create */ }
catch (Exception e) when (e.Message.Contains("CreateRobotArgs error")) {
Log.Console($"Invalid CreateRobot arguments. Usage: CreateRobot --num <N>. Detail: {e.Message}");
} Prevention
- Run the console command bare first to see auto-generated help.
- Keep CreateRobotArgs field names in sync with documented usage.
- Include the real parser errors in the exception message to aid debugging.
When it happens
Trigger: Issuing the 'CreateRobot' console command with arguments that fail to bind to CreateRobotArgs (wrong types, missing required values, unknown verbs). The generic WithNotParsed callback throws regardless of the specific parser error.
Common situations: Typing the CreateRobot console command with malformed arguments (e.g. bad --num value, non-integer, missing flag); version mismatch where CreateRobotArgs gained new required fields; copy-pasting a command from docs that don't match current options.
Related errors
- RemoveRobot error!
- ConsoleHandler handler not inherit IConsoleHandler class: {o
- RouterManager fiber not found under fiber: {self.Fiber().Nam
- RouterManagerAddressComponent is missing on RouterManager sc
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/038575c859f0cc9c.
Report an issue: GitHub.