From 03b61e4a5a5e3338400882776b99be6a221e6679 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 22 Jan 2020 20:00:36 +0900 Subject: [PATCH] Throw exception rather than returning nulls --- osu.Game/Online/API/APIMod.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/API/APIMod.cs b/osu.Game/Online/API/APIMod.cs index 30336d16a3..46a8db31b7 100644 --- a/osu.Game/Online/API/APIMod.cs +++ b/osu.Game/Online/API/APIMod.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using System.Linq; using Humanizer; @@ -38,7 +39,7 @@ namespace osu.Game.Online.API Mod resultMod = ruleset.GetAllMods().FirstOrDefault(m => m.Acronym == Acronym); if (resultMod == null) - return null; // Todo: Maybe throw exception? + throw new InvalidOperationException($"There is no mod in the ruleset ({ruleset.ShortName}) matching the acronym {Acronym}."); foreach (var (_, property) in resultMod.GetSettingsSourceProperties()) {