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);
|
||||
|
||||
}
|
||||
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(' '))
|
||||
{
|
||||
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(' ');
|
||||
List<string> argumentsList = new List<string>();
|
||||
|
||||
@ -55,7 +55,7 @@ namespace RecrownedAthenaeum.Tools.CommandProcessor
|
||||
i++;
|
||||
if (i >= argumentsSplit.Length)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
throw new ArgumentException("Argument is missing terminating \'\"\'");
|
||||
}
|
||||
|
||||
} while (!argumentsSplit[i].Contains('"'));
|
||||
@ -70,7 +70,7 @@ namespace RecrownedAthenaeum.Tools.CommandProcessor
|
||||
}
|
||||
arguments = argumentsList.ToArray();
|
||||
}
|
||||
if (!commands.ContainsKey(command)) throw new ArgumentException();
|
||||
if (!commands.ContainsKey(command)) throw new ArgumentException("Command not found.");
|
||||
commands[command].Run(arguments);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user