1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 07:02:54 +08:00

Throw and log instead of silently failing on type/instance creation failure

This commit is contained in:
Dean Herbert 2021-10-14 14:24:36 +09:00
parent 364fa068b3
commit 4ed794e434

View File

@ -147,12 +147,12 @@ namespace osu.Game.Stores
var type = Type.GetType(r.InstantiationInfo); var type = Type.GetType(r.InstantiationInfo);
if (type == null) if (type == null)
continue; throw new InvalidOperationException(@"Type resolution failure.");
var rInstance = (Activator.CreateInstance(type) as Ruleset)?.RulesetInfo; var rInstance = (Activator.CreateInstance(type) as Ruleset)?.RulesetInfo;
if (rInstance == null) if (rInstance == null)
continue; throw new InvalidOperationException(@"Instantiation failure.");
r.Name = rInstance.Name; r.Name = rInstance.Name;
r.ShortName = rInstance.ShortName; r.ShortName = rInstance.ShortName;
@ -161,9 +161,10 @@ namespace osu.Game.Stores
detachedRulesets.Add(r.Clone()); detachedRulesets.Add(r.Clone());
} }
catch catch (Exception ex)
{ {
r.Available = false; r.Available = false;
Logger.Log($"Could not load ruleset {r}: {ex.Message}");
} }
} }