Use name of for exceptions.

This commit is contained in:
Matthias Mailänder
2025-07-21 12:57:40 +02:00
committed by Gustas Kažukauskas
parent a4966bc299
commit 53f959e4bf
4 changed files with 5 additions and 5 deletions

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Widgets
world = wr.World;
terrainInfo = world.Map.Rules.TerrainInfo as ITemplatedTerrainInfo;
if (terrainInfo == null)
throw new InvalidDataException("EditorTileBrush can only be used with template-based tilesets");
throw new InvalidDataException($"{nameof(EditorTileBrush)} can only be used with template-based tilesets");
editorActionManager = world.WorldActor.Trait<EditorActionManager>();
terrainRenderer = world.WorldActor.Trait<ITiledTerrainRenderer>();

View File

@@ -62,10 +62,10 @@ namespace OpenRA.Mods.Common.Traits
{
var grid = Game.ModData.Manifest.Get<MapGrid>();
if (grid.Type != MapGridType.RectangularIsometric)
throw new YamlException("IsometricSelectable can only be used in mods that use the RectangularIsometric MapGrid type.");
throw new YamlException($"{nameof(IsometricSelectable)} can only be used in mods that use the {nameof(MapGridType.RectangularIsometric)} MapGrid type.");
if (Height == 0 && DecorationHeight <= 0)
throw new YamlException("DecorationHeight must be defined and greater than 0 if Height is 0.");
throw new YamlException($"{nameof(DecorationHeight)} must be defined and greater than 0 if Height is 0.");
}
}

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
if (!rules.Actors[SystemActors.World].HasTraitInfo<TerrainLightingInfo>())
throw new YamlException("TerrainLightSource can only be used with the world TerrainLighting trait.");
throw new YamlException($"{nameof(TerrainLightSource)} can only be used with the world {nameof(TerrainLighting)} trait.");
}
public override object Create(ActorInitializer init) { return new TerrainLightSource(init.Self, this); }

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits
map = world.Map;
terrainInfo = map.Rules.TerrainInfo as DefaultTerrain;
if (terrainInfo == null)
throw new InvalidDataException("TerrainRenderer can only be used with the DefaultTerrain parser");
throw new InvalidDataException($"{nameof(TerrainRenderer)} can only be used with the {nameof(DefaultTerrain)} parser");
tileCache = new DefaultTileCache(terrainInfo);
}