Fix misleading Utility message
We were reporting that the entered command did not exist by assuming that any ArgumentException indicated this. Now we will throw and catch a NoSuchCommandException.
This commit is contained in:
@@ -15,6 +15,16 @@ using OpenRA.FileSystem;
|
|||||||
|
|
||||||
namespace OpenRA.Utility
|
namespace OpenRA.Utility
|
||||||
{
|
{
|
||||||
|
public class NoSuchCommandException : Exception
|
||||||
|
{
|
||||||
|
public readonly string Command;
|
||||||
|
public NoSuchCommandException(string command)
|
||||||
|
: base("No such command '{0}'".F(command))
|
||||||
|
{
|
||||||
|
Command = command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
@@ -57,7 +67,7 @@ namespace OpenRA.Utility
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!actions.ContainsKey(args[0]))
|
if (!actions.ContainsKey(args[0]))
|
||||||
throw new ArgumentException();
|
throw new NoSuchCommandException(args[0]);
|
||||||
|
|
||||||
var action = actions[args[0]].Key;
|
var action = actions[args[0]].Key;
|
||||||
var validateActionArgs = actions[args[0]].Value;
|
var validateActionArgs = actions[args[0]].Value;
|
||||||
@@ -78,13 +88,13 @@ namespace OpenRA.Utility
|
|||||||
Log.Write("utility", "Received args: {0}", args.JoinWith(" "));
|
Log.Write("utility", "Received args: {0}", args.JoinWith(" "));
|
||||||
Log.Write("utility", "{0}", e);
|
Log.Write("utility", "{0}", e);
|
||||||
|
|
||||||
if (e is ArgumentException)
|
if (e is NoSuchCommandException)
|
||||||
Console.WriteLine("No such command '{0}'", args[0]);
|
Console.WriteLine(e.Message);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("Error: Utility application crashed. See utility.log for details");
|
Console.WriteLine("Error: Utility application crashed. See utility.log for details");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user