1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:43:05 +08:00

Centralise logging of failed ruleset loads

This commit is contained in:
Dean Herbert 2022-08-18 16:14:38 +09:00
parent e0edaf996f
commit b0a740071e
2 changed files with 9 additions and 5 deletions

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
@ -91,8 +90,7 @@ namespace osu.Game.Rulesets
catch (Exception ex) catch (Exception ex)
{ {
r.Available = false; r.Available = false;
Logger.Log($"Could not load ruleset {r.Name}. Please check for an update from the developer.", level: LogLevel.Error); LogFailedLoad(r.Name, ex);
Logger.Log($"Ruleset load failed with {ex.Message}");
} }
} }

View File

@ -138,7 +138,7 @@ namespace osu.Game.Rulesets
} }
catch (Exception e) catch (Exception e)
{ {
Logger.Error(e, $"Failed to load ruleset {filename}"); LogFailedLoad(filename, e);
} }
} }
@ -158,7 +158,7 @@ namespace osu.Game.Rulesets
} }
catch (Exception e) catch (Exception e)
{ {
Logger.Error(e, $"Failed to add ruleset {assembly}"); LogFailedLoad(assembly.FullName, e);
} }
} }
@ -173,6 +173,12 @@ namespace osu.Game.Rulesets
AppDomain.CurrentDomain.AssemblyResolve -= resolveRulesetDependencyAssembly; AppDomain.CurrentDomain.AssemblyResolve -= resolveRulesetDependencyAssembly;
} }
protected void LogFailedLoad(string name, Exception exception)
{
Logger.Log($"Could not load ruleset {name}. Please check for an update from the developer.", level: LogLevel.Error);
Logger.Log($"Ruleset load failed: {exception}");
}
#region Implementation of IRulesetStore #region Implementation of IRulesetStore
IRulesetInfo? IRulesetStore.GetRuleset(int id) => GetRuleset(id); IRulesetInfo? IRulesetStore.GetRuleset(int id) => GetRuleset(id);