1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 17:27:39 +08:00
osu-lazer/osu.Game/Rulesets
Dean Herbert 0267aed846 Change ToMod to return an UnknownMod rather than throw if a mod isn't available
As seen by this kind of crash, having the `.ToMod` method throw can be
very problematic and also hidden (as it is used inside of models in
places where exceptions are not expected to occur).

Given there are tens of usages of this method, returning a placeholder
mod seems like a better idea than outright throwing.

```
 An unhandled has occurred.
 System.InvalidOperationException:
There is no mod in the ruleset (osu) matching the acronym AS.
 at osu.Game.Online.API.APIMod.ToMod(Ruleset ruleset) in /Users/dean/Projects/osu/osu.Game/Online/API/APIMod.cs:line 54
 at osu.Game.Scoring.ScoreInfo.<get_Mods>b__117_0(APIMod m) in /Users/dean/Projects/osu/osu.Game/Scoring/ScoreInfo.cs:line 193
 at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
 at osu.Game.Scoring.ScoreInfo.get_Mods() in /Users/dean/Projects/osu/osu.Game/Scoring/ScoreInfo.cs:line 193
 at osu.Game.Screens.Select.Leaderboards.BeatmapLeaderboard.<>c.<subscribeToLocalScores>b__40_2(ScoreInfo s) in /Users/dean/Projects/osu/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs:line 199
 at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
 at osu.Game.Database.RealmObjectExtensions.Detach[T](IEnumerable`1 items) in /Users/dean/Projects/osu/osu.Game/Database/RealmObjectExtensions.cs:line 180
 at osu.Game.Screens.Select.Leaderboards.BeatmapLeaderboard.<>c__DisplayClass40_0.<subscribeToLocalScores>g__localScoresChanged|1(IRealmCollection`1 sender, ChangeSet changes, Exception exception) in /Users/dean/Projects/osu/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs:line
209
 at Realms.RealmCollectionBase`1.Realms.INotifiable<Realms.NotifiableObjectHandleBase.CollectionChangeSet>.NotifyCallbacks(Nullable`1 changes, Nullable`1 exception)
 at Realms.NotifiableObjectHandleBase.NotifyObjectChanged(IntPtr managedHandle, IntPtr changes, IntPtr exception)
```
2022-03-09 17:57:55 +09:00
..
Configuration Update remaining cases of clashes with realm.Write and realm.RegisterForNotifications 2022-01-25 13:09:48 +09:00
Difficulty Add XMLDocs to difficulty attribute properties 2022-02-16 14:09:19 +09:00
Edit Move files to UI namespace 2022-02-14 17:51:39 +09:00
Filter Rename all remaining cases 2021-10-03 00:55:29 +09:00
Judgements Fix osu! judgements getting scaled twice over different durations 2021-09-02 16:31:43 +09:00
Mods Change ToMod to return an UnknownMod rather than throw if a mod isn't available 2022-03-09 17:57:55 +09:00
Objects Replace TimeSignatures enum with struct for storage of arbitrary meter 2022-01-22 20:50:31 +01:00
Replays Add replay statistics frames to FramedReplayInputHandler 2022-01-31 18:53:47 +09:00
Scoring Merge pull request #17157 from peppy/fix-statistics-json-serialisation 2022-03-08 20:20:31 +09:00
Timing Rename ApproachRate to ScrollSpeed for now (to reduce complexity/confusion) 2021-09-06 21:06:13 +09:00
UI Only call IUpdatableByPlayfield.Update if the playfield isn't nested 2022-03-03 14:37:39 +08:00
AssemblyRulesetStore.cs Add xmldoc and allow constructing an AssemblyRulesetStore with a directory path 2022-02-16 17:25:16 +09:00
EFRulesetInfo.cs Update pointless CompareTo implementation once again 2022-02-11 04:17:30 +03:00
ILegacyRuleset.cs Apply review suggestions 2020-12-03 19:44:12 +02:00
IRulesetConfigCache.cs Extract interface for ruleset config cache 2021-12-23 18:59:02 +01:00
IRulesetInfo.cs Allow IRulesetInfos of same type to be comparable 2022-02-11 04:03:23 +03:00
IRulesetStore.cs Add IRulesetStore to allow for transitional usage in upcoming manager classes 2021-12-03 17:57:40 +09:00
RealmRulesetStore.cs Split out realm portion of RulesetStore 2022-02-16 17:13:31 +09:00
Ruleset.cs Make Ruleset.RulesetInfo get only 2022-01-27 15:36:35 +09:00
RulesetConfigCache.cs Rename RealmContextFactory to RealmAccess 2022-01-24 20:38:07 +09:00
RulesetInfo.cs Introduce private APIRuleset for online ID equality comparison 2022-02-11 08:27:01 +03:00
RulesetLoadException.cs Throw again to ensure correct available state is set 2021-11-11 17:39:36 +09:00
RulesetSelector.cs General refactoring 2019-06-26 17:52:25 +09:00
RulesetStore.cs Split out realm portion of RulesetStore 2022-02-16 17:13:31 +09:00