From 69850cb1143110877ad0eea206a6537fe42c9063 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 11 May 2018 12:18:46 -0400 Subject: [PATCH] fix error when game looks up dialogue for a pet/horse with special characters in their name (#505) --- src/SMAPI/Framework/SContentManager.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SMAPI/Framework/SContentManager.cs b/src/SMAPI/Framework/SContentManager.cs index 9353ee29..e97e655d 100644 --- a/src/SMAPI/Framework/SContentManager.cs +++ b/src/SMAPI/Framework/SContentManager.cs @@ -218,14 +218,16 @@ namespace StardewModdingAPI.Framework /// Assert that the given key has a valid format. /// The asset key to check. - /// The asset key is empty or contains invalid characters. + /// The asset key is empty or contains invalid characters. [SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local", Justification = "Parameter is only used for assertion checks by design.")] public void AssertValidAssetKeyFormat(string key) { + // NOTE: the game checks for ContentLoadException to handle invalid keys, so avoid + // throwing other types like ArgumentException here. if (string.IsNullOrWhiteSpace(key)) - throw new ArgumentException("The asset key or local path is empty."); + throw new SContentLoadException("The asset key or local path is empty."); if (key.Intersect(Path.GetInvalidPathChars()).Any()) - throw new ArgumentException("The asset key or local path contains invalid characters."); + throw new SContentLoadException("The asset key or local path contains invalid characters."); } /// Convert an absolute file path into an appropriate asset name.