Added try/catch for TypeDictionary errors in Lint code
TypeDictionary errors are very hard for modders to debug as they don't mention which actor is causing the error
This commit is contained in:
@@ -33,13 +33,21 @@ namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
foreach (var actorInfo in rules.Actors)
|
||||
{
|
||||
var health = actorInfo.Value.TraitInfoOrDefault<IHealthInfo>();
|
||||
if (health == null)
|
||||
continue;
|
||||
// Catch TypeDictionary errors
|
||||
try
|
||||
{
|
||||
var health = actorInfo.Value.TraitInfoOrDefault<IHealthInfo>();
|
||||
if (health == null)
|
||||
continue;
|
||||
|
||||
var hitShapes = actorInfo.Value.TraitInfos<HitShapeInfo>();
|
||||
if (!hitShapes.Any())
|
||||
emitError($"Actor type `{actorInfo.Key}` has a Health trait but no HitShape trait!");
|
||||
var hitShapes = actorInfo.Value.TraitInfos<HitShapeInfo>();
|
||||
if (!hitShapes.Any())
|
||||
emitError($"Actor type `{actorInfo.Key}` has a Health trait but no HitShape trait!");
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
emitError($"{e.Message} (Actor type `{actorInfo.Key}`)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user