diff options
Diffstat (limited to 'src/SMAPI/Framework/ContentManagers/ModContentManager.cs')
-rw-r--r-- | src/SMAPI/Framework/ContentManagers/ModContentManager.cs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs index badbd766..2c068784 100644 --- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs @@ -130,7 +130,7 @@ namespace StardewModdingAPI.Framework.ContentManagers ".png" => this.LoadImageFile<T>(assetName, file), ".tbin" or ".tmx" => this.LoadMapFile<T>(assetName, file), ".xnb" => this.LoadXnbFile<T>(assetName), - _ => this.HandleUnknownFileType<T>(assetName, file) + _ => (T)this.HandleUnknownFileType(assetName, file, typeof(T)) }; } catch (Exception ex) @@ -323,13 +323,15 @@ namespace StardewModdingAPI.Framework.ContentManagers } /// <summary>Handle a request to load a file type that isn't supported by SMAPI.</summary> - /// <typeparam name="T">The expected file type.</typeparam> /// <param name="assetName">The asset name relative to the loader root directory.</param> /// <param name="file">The file to load.</param> - private T HandleUnknownFileType<T>(IAssetName assetName, FileInfo file) + /// <param name="assetType">The expected file type.</param> + private object HandleUnknownFileType(IAssetName assetName, FileInfo file, Type assetType) { this.ThrowLoadError(assetName, ContentLoadErrorType.InvalidName, $"unknown file extension '{file.Extension}'; must be one of '.fnt', '.json', '.png', '.tbin', '.tmx', or '.xnb'."); - return default; + return assetType.IsValueType + ? Activator.CreateInstance(assetType) + : null; } /// <summary>Assert that the asset type is compatible with one of the allowed types.</summary> |