throw with a more helpful error than NullReferenceException

closes #5622
This commit is contained in:
Matthias Mailänder
2014-06-28 11:18:24 +02:00
parent 1c511ea6eb
commit aae428be2b

View File

@@ -234,7 +234,7 @@ namespace OpenRA.Mods.RA.AI
ActorInfo GetInfoByCommonName(Dictionary<string, string[]> names, string commonName, Player owner)
{
if (!names.Any() || !names.ContainsKey(commonName))
return null;
throw new InvalidOperationException("Can't find {0} in the HackyAI UnitsCommonNames definition.".F(commonName));
return Map.Rules.Actors.Where(k => names[commonName].Contains(k.Key)).Random(random).Value;
}