1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 12:58:33 +01:00

throw in ContentExtensions when a json file is not found

This commit is contained in:
Ell 2020-11-21 22:49:22 +01:00
parent c4114c73f8
commit 6e7720295f

View file

@ -56,8 +56,10 @@ namespace MLEM.Data {
/// <typeparam name="T">The type of asset to load</typeparam>
/// <returns>The loaded asset</returns>
public static T LoadJson<T>(this ContentManager content, string name, string[] extensions = null) {
var triedFiles = new List<string>();
foreach (var extension in extensions ?? JsonExtensions) {
var file = Path.Combine(content.RootDirectory, name + extension);
triedFiles.Add(file);
if (!File.Exists(file))
continue;
using (var stream = File.OpenText(file)) {
@ -66,7 +68,7 @@ namespace MLEM.Data {
}
}
}
return default;
throw new ContentLoadException($"Asset {name} not found. Tried files {string.Join(", ", triedFiles)}");
}
}