1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 17:53:15 +08:00

Avoid catching all exceptions raising from skin instance creation

This commit is contained in:
Salman Ahmed 2022-09-20 22:27:27 +03:00
parent ff56821152
commit b8f2e13503

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations; using JetBrains.Annotations;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.IO; using osu.Game.IO;
@ -45,20 +44,18 @@ namespace osu.Game.Skinning
var type = string.IsNullOrEmpty(InstantiationInfo) var type = string.IsNullOrEmpty(InstantiationInfo)
// handle the case of skins imported before InstantiationInfo was added. // handle the case of skins imported before InstantiationInfo was added.
? typeof(LegacySkin) ? typeof(LegacySkin)
: Type.GetType(InstantiationInfo).AsNonNull(); : Type.GetType(InstantiationInfo);
try if (type == null)
{ {
return (Skin)Activator.CreateInstance(type, this, resources); // Since the class was renamed from "DefaultSkin" to "TrianglesSkin", the type retrieval would fail
}
catch
{
// Since the class was renamed from "DefaultSkin" to "TrianglesSkin", the instantiation would fail
// for user modified skins. This aims to amicably handle that. // for user modified skins. This aims to amicably handle that.
// If we ever add more default skins in the future this will need some kind of proper migration rather than // If we ever add more default skins in the future this will need some kind of proper migration rather than
// a single catch. // a single fallback.
return new TrianglesSkin(this, resources); return new TrianglesSkin(this, resources);
} }
return (Skin)Activator.CreateInstance(type, this, resources);
} }
public IList<RealmNamedFileUsage> Files { get; } = null!; public IList<RealmNamedFileUsage> Files { get; } = null!;