From ad1a19000fe4819383d039192004f72da44064ca Mon Sep 17 00:00:00 2001 From: goat Date: Sat, 29 Jun 2024 19:06:23 +0200 Subject: [PATCH] throw less-generic exception if icon lookup failed --- .../Textures/Internal/IconNotFoundException.cs | 17 +++++++++++++++++ .../Internal/TextureManager.SharedTextures.cs | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 Dalamud/Interface/Textures/Internal/IconNotFoundException.cs diff --git a/Dalamud/Interface/Textures/Internal/IconNotFoundException.cs b/Dalamud/Interface/Textures/Internal/IconNotFoundException.cs new file mode 100644 index 000000000..aa098ff45 --- /dev/null +++ b/Dalamud/Interface/Textures/Internal/IconNotFoundException.cs @@ -0,0 +1,17 @@ +namespace Dalamud.Interface.Textures.Internal; + +/// +/// Exception thrown when an icon could not be found. +/// +public class IconNotFoundException : Exception +{ + /// + /// Initializes a new instance of the class. + /// + /// The lookup that was used to find the icon. + internal IconNotFoundException(GameIconLookup lookup) + : base($"The icon with the ID {lookup.IconId} {(lookup.HiRes ? "HiRes" : string.Empty)} {(lookup.ItemHq ? "ItemHq" : string.Empty)} " + + $"with language {lookup.Language} was not found.") + { + } +} diff --git a/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs b/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs index dc0cb0f0f..d6c2fb346 100644 --- a/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs +++ b/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs @@ -137,7 +137,7 @@ internal sealed partial class TextureManager [MethodImpl(MethodImplOptions.AggressiveInlining)] private string GetIconPathByValue(GameIconLookup lookup) => - this.textureManager.TryGetIconPath(lookup, out var path) ? path : throw new FileNotFoundException(); + this.textureManager.TryGetIconPath(lookup, out var path) ? path : throw new IconNotFoundException(lookup); private void FrameworkOnUpdate(IFramework unused) {