added proper error reporting to command engine.
This commit is contained in:
parent
6c37b11e07
commit
7718a98d1a
@ -24,9 +24,9 @@ namespace RecrownedAthenaeum.Tools.CommandProcessor
|
|||||||
Process(command);
|
Process(command);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException ae)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Command not found.");
|
Console.WriteLine("Error: " + ae.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ namespace RecrownedAthenaeum.Tools.CommandProcessor
|
|||||||
if (commandAndArguments.Contains(' '))
|
if (commandAndArguments.Contains(' '))
|
||||||
{
|
{
|
||||||
command = command.Remove(command.IndexOf(' '));
|
command = command.Remove(command.IndexOf(' '));
|
||||||
if (!commands.ContainsKey(command)) throw new ArgumentException();
|
if (!commands.ContainsKey(command)) throw new ArgumentException("Command not found.");
|
||||||
string[] argumentsSplit = commandAndArguments.Remove(command.Length).Split(' ');
|
string[] argumentsSplit = commandAndArguments.Remove(command.Length).Split(' ');
|
||||||
List<string> argumentsList = new List<string>();
|
List<string> argumentsList = new List<string>();
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ namespace RecrownedAthenaeum.Tools.CommandProcessor
|
|||||||
i++;
|
i++;
|
||||||
if (i >= argumentsSplit.Length)
|
if (i >= argumentsSplit.Length)
|
||||||
{
|
{
|
||||||
throw new ArgumentException();
|
throw new ArgumentException("Argument is missing terminating \'\"\'");
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (!argumentsSplit[i].Contains('"'));
|
} while (!argumentsSplit[i].Contains('"'));
|
||||||
@ -70,7 +70,7 @@ namespace RecrownedAthenaeum.Tools.CommandProcessor
|
|||||||
}
|
}
|
||||||
arguments = argumentsList.ToArray();
|
arguments = argumentsList.ToArray();
|
||||||
}
|
}
|
||||||
if (!commands.ContainsKey(command)) throw new ArgumentException();
|
if (!commands.ContainsKey(command)) throw new ArgumentException("Command not found.");
|
||||||
commands[command].Run(arguments);
|
commands[command].Run(arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user