From 7718a98d1a10602b4bd7b2bb69bdb120ad35f2b1 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Sat, 8 Dec 2018 16:32:01 -0600 Subject: [PATCH] added proper error reporting to command engine. --- .../CommandProcessor/CommandEngine.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RecrownedAthenaeum.ConsoleTools/CommandProcessor/CommandEngine.cs b/RecrownedAthenaeum.ConsoleTools/CommandProcessor/CommandEngine.cs index 644b8b1..793928c 100644 --- a/RecrownedAthenaeum.ConsoleTools/CommandProcessor/CommandEngine.cs +++ b/RecrownedAthenaeum.ConsoleTools/CommandProcessor/CommandEngine.cs @@ -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 argumentsList = new List(); @@ -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); } }