mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:02:55 +08:00
CA2201: throw correct exception type.
This commit is contained in:
parent
ecfc6dfa3d
commit
d7b3578cc6
@ -57,4 +57,7 @@
|
|||||||
<Rule Id="CA2213" Action="None" />
|
<Rule Id="CA2213" Action="None" />
|
||||||
<Rule Id="CA2235" Action="None" />
|
<Rule Id="CA2235" Action="None" />
|
||||||
</Rules>
|
</Rules>
|
||||||
|
<Rules AnalyzerId="Microsoft.NetCore.CSharp.Analyzers" RuleNamespace="Microsoft.NetCore.CSharp.Analyzers">
|
||||||
|
<Rule Id="CA2201" Action="Warning" />
|
||||||
|
</Rules>
|
||||||
</RuleSet>
|
</RuleSet>
|
@ -111,7 +111,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
foreach (var type in requiredGameDependencies)
|
foreach (var type in requiredGameDependencies)
|
||||||
{
|
{
|
||||||
if (game.Dependencies.Get(type) == null)
|
if (game.Dependencies.Get(type) == null)
|
||||||
throw new Exception($"{type} has not been cached");
|
throw new InvalidOperationException($"{type} has not been cached");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -121,7 +121,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
foreach (var type in requiredGameBaseDependencies)
|
foreach (var type in requiredGameBaseDependencies)
|
||||||
{
|
{
|
||||||
if (gameBase.Dependencies.Get(type) == null)
|
if (gameBase.Dependencies.Get(type) == null)
|
||||||
throw new Exception($"{type} has not been cached");
|
throw new InvalidOperationException($"{type} has not been cached");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -122,7 +122,7 @@ namespace osu.Game.Online.API
|
|||||||
// attempt to decode a displayable error string.
|
// attempt to decode a displayable error string.
|
||||||
var error = JsonConvert.DeserializeObject<DisplayableError>(responseString);
|
var error = JsonConvert.DeserializeObject<DisplayableError>(responseString);
|
||||||
if (error != null)
|
if (error != null)
|
||||||
e = new Exception(error.ErrorMessage, e);
|
e = new APIException(error.ErrorMessage, e);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -154,6 +154,14 @@ namespace osu.Game.Online.API
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class APIException : InvalidOperationException
|
||||||
|
{
|
||||||
|
public APIException(string messsage, Exception innerException)
|
||||||
|
: base(messsage, innerException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public delegate void APIFailureHandler(Exception e);
|
public delegate void APIFailureHandler(Exception e);
|
||||||
|
|
||||||
public delegate void APISuccessHandler();
|
public delegate void APISuccessHandler();
|
||||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Difficulty.Utils
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (i < 0 || i > Count - 1)
|
if (i < 0 || i > Count - 1)
|
||||||
throw new IndexOutOfRangeException();
|
throw new ArgumentOutOfRangeException(nameof(i));
|
||||||
|
|
||||||
i += marker;
|
i += marker;
|
||||||
if (i > capacity - 1)
|
if (i > capacity - 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user