From 53f959e4bf5140bd32c2d04e6de9fbc495e5433a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Mon, 21 Jul 2025 12:57:40 +0200 Subject: [PATCH] Use name of for exceptions. --- OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs | 2 +- OpenRA.Mods.Common/Traits/IsometricSelectable.cs | 4 ++-- OpenRA.Mods.Common/Traits/TerrainLightSource.cs | 2 +- OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs index 42e20200cf..d30bfc319b 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs @@ -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(); terrainRenderer = world.WorldActor.Trait(); diff --git a/OpenRA.Mods.Common/Traits/IsometricSelectable.cs b/OpenRA.Mods.Common/Traits/IsometricSelectable.cs index d39b0aff42..d784b9c054 100644 --- a/OpenRA.Mods.Common/Traits/IsometricSelectable.cs +++ b/OpenRA.Mods.Common/Traits/IsometricSelectable.cs @@ -62,10 +62,10 @@ namespace OpenRA.Mods.Common.Traits { var grid = Game.ModData.Manifest.Get(); 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."); } } diff --git a/OpenRA.Mods.Common/Traits/TerrainLightSource.cs b/OpenRA.Mods.Common/Traits/TerrainLightSource.cs index 432edafdec..3086b33201 100644 --- a/OpenRA.Mods.Common/Traits/TerrainLightSource.cs +++ b/OpenRA.Mods.Common/Traits/TerrainLightSource.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits public void RulesetLoaded(Ruleset rules, ActorInfo ai) { if (!rules.Actors[SystemActors.World].HasTraitInfo()) - 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); } diff --git a/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs b/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs index de00ab4e6a..690f38117f 100644 --- a/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs +++ b/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs @@ -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); }