Use SingleOrDefault for added safety when looking up mod acronyms

This commit is contained in:
Dean Herbert
2021-01-03 15:38:28 +09:00
parent 8511112e28
commit 1a44338124

View File

@ -36,7 +36,7 @@ namespace osu.Game.Online.API
public Mod ToMod(Ruleset ruleset)
{
Mod resultMod = ruleset.GetAllMods().FirstOrDefault(m => m.Acronym == Acronym);
Mod resultMod = ruleset.GetAllMods().SingleOrDefault(m => m.Acronym == Acronym);
if (resultMod == null)
throw new InvalidOperationException($"There is no mod in the ruleset ({ruleset.ShortName}) matching the acronym {Acronym}.");