1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 05:27:23 +08:00

Change exceptions which should be returned to the user to HubException type

See
https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.signalr.hubexception?view=aspnetcore-5.0.
This commit is contained in:
Dean Herbert 2020-12-09 14:46:43 +09:00
parent 48129c52d6
commit c92c2cbfc0
4 changed files with 36 additions and 4 deletions

View File

@ -2,14 +2,22 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Runtime.Serialization;
using Microsoft.AspNetCore.SignalR;
namespace osu.Game.Online.RealtimeMultiplayer
{
public class AlreadyInRoomException : Exception
[Serializable]
public class AlreadyInRoomException : HubException
{
public AlreadyInRoomException()
: base("This user is already in a multiplayer room.")
{
}
protected AlreadyInRoomException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

View File

@ -2,14 +2,22 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Runtime.Serialization;
using Microsoft.AspNetCore.SignalR;
namespace osu.Game.Online.RealtimeMultiplayer
{
public class InvalidStateChangeException : Exception
[Serializable]
public class InvalidStateChangeException : HubException
{
public InvalidStateChangeException(MultiplayerUserState oldState, MultiplayerUserState newState)
: base($"Cannot change from {oldState} to {newState}")
{
}
protected InvalidStateChangeException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

View File

@ -2,14 +2,22 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Runtime.Serialization;
using Microsoft.AspNetCore.SignalR;
namespace osu.Game.Online.RealtimeMultiplayer
{
public class NotHostException : Exception
[Serializable]
public class NotHostException : HubException
{
public NotHostException()
: base("User is attempting to perform a host level operation while not the host")
{
}
protected NotHostException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

View File

@ -2,14 +2,22 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Runtime.Serialization;
using Microsoft.AspNetCore.SignalR;
namespace osu.Game.Online.RealtimeMultiplayer
{
public class NotJoinedRoomException : Exception
[Serializable]
public class NotJoinedRoomException : HubException
{
public NotJoinedRoomException()
: base("This user has not yet joined a multiplayer room.")
{
}
protected NotJoinedRoomException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}