From c92c2cbfc01716b553369e376b9754d9f70c5262 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 9 Dec 2020 14:46:43 +0900 Subject: [PATCH] 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. --- .../RealtimeMultiplayer/AlreadyInRoomException.cs | 10 +++++++++- .../RealtimeMultiplayer/InvalidStateChangeException.cs | 10 +++++++++- .../Online/RealtimeMultiplayer/NotHostException.cs | 10 +++++++++- .../RealtimeMultiplayer/NotJoinedRoomException.cs | 10 +++++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/osu.Game/Online/RealtimeMultiplayer/AlreadyInRoomException.cs b/osu.Game/Online/RealtimeMultiplayer/AlreadyInRoomException.cs index f99bea651c..7f3c2b339a 100644 --- a/osu.Game/Online/RealtimeMultiplayer/AlreadyInRoomException.cs +++ b/osu.Game/Online/RealtimeMultiplayer/AlreadyInRoomException.cs @@ -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) + { + } } } diff --git a/osu.Game/Online/RealtimeMultiplayer/InvalidStateChangeException.cs b/osu.Game/Online/RealtimeMultiplayer/InvalidStateChangeException.cs index 1e33f55491..d9a276fc19 100644 --- a/osu.Game/Online/RealtimeMultiplayer/InvalidStateChangeException.cs +++ b/osu.Game/Online/RealtimeMultiplayer/InvalidStateChangeException.cs @@ -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) + { + } } } diff --git a/osu.Game/Online/RealtimeMultiplayer/NotHostException.cs b/osu.Game/Online/RealtimeMultiplayer/NotHostException.cs index e421c6ae28..56095043f0 100644 --- a/osu.Game/Online/RealtimeMultiplayer/NotHostException.cs +++ b/osu.Game/Online/RealtimeMultiplayer/NotHostException.cs @@ -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) + { + } } } diff --git a/osu.Game/Online/RealtimeMultiplayer/NotJoinedRoomException.cs b/osu.Game/Online/RealtimeMultiplayer/NotJoinedRoomException.cs index d71200a086..7a6e089d0b 100644 --- a/osu.Game/Online/RealtimeMultiplayer/NotJoinedRoomException.cs +++ b/osu.Game/Online/RealtimeMultiplayer/NotJoinedRoomException.cs @@ -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) + { + } } }