1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 20:59:35 +08:00
osu-lazer/osu.Game/Online/API
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
..
Requests Replace string locale with Language 2022-03-04 00:57:13 -06:00
APIAccess.cs Add API versioning 2022-02-21 19:02:03 +09:00
APIDownloadRequest.cs Apply batch fixing of built-in types using var 2021-10-27 13:04:41 +09:00
APIException.cs Fix clear identifier typos 2021-12-27 20:26:28 -08:00
APIMessagesRequest.cs Update licence header (and remove year) 2019-01-24 17:43:03 +09:00
APIMod.cs Change ToMod to return an UnknownMod rather than throw if a mod isn't available 2022-03-09 17:57:55 +09:00
APIRequest.cs Add API versioning 2022-02-21 19:02:03 +09:00
APIRequestCompletionState.cs Fix API request potentially firing failed events after completion 2021-07-19 20:27:01 +09:00
ArchiveDownloadRequest.cs Enforce one missed property back to single-floating type 2021-01-18 22:07:25 +03:00
DummyAPIAccess.cs Add API versioning 2022-02-21 19:02:03 +09:00
IAPIProvider.cs Add API versioning 2022-02-21 19:02:03 +09:00
ModSettingsDictionaryFormatter.cs Extract mod setting value handling to utils class 2021-04-12 03:37:03 +03:00
OAuth.cs Fix intendation in a way it doesn't regress with older inspectcode 2021-10-18 14:28:29 +09:00
OAuthToken.cs Merge branch 'master' into more-inspections 2019-02-28 14:32:57 +09:00
OsuJsonWebRequest.cs Fix json web requests having incorrect user agents 2020-01-17 19:21:27 +09:00
OsuWebRequest.cs Fix user agent missing in registration 2020-01-16 12:51:43 +09:00
RegistrationRequest.cs Fix user agent missing in registration 2020-01-16 12:51:43 +09:00