From 7db6eefc3719870611e4c19f0cad7f8969d838e7 Mon Sep 17 00:00:00 2001 From: tudor <7089284+tudddorrr@users.noreply.github.com> Date: Sat, 4 Jul 2026 14:11:29 +0100 Subject: [PATCH 1/2] make exceptions slightly more consistent --- .../Runtime/Utils/ContinuityReplayException.cs | 2 +- .../Talo/Runtime/Utils/PlayerAuthException.cs | 17 +++++++++++++---- .../Talo/Runtime/Utils/SocketException.cs | 17 +++++++++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/ContinuityReplayException.cs b/Assets/Talo Game Services/Talo/Runtime/Utils/ContinuityReplayException.cs index 3ba32991..b646d20d 100644 --- a/Assets/Talo Game Services/Talo/Runtime/Utils/ContinuityReplayException.cs +++ b/Assets/Talo Game Services/Talo/Runtime/Utils/ContinuityReplayException.cs @@ -5,7 +5,7 @@ namespace TaloGameServices { public class ContinuityReplayException : Exception { - private List _exceptions; + private readonly List _exceptions; public List Exceptions => _exceptions; public ContinuityReplayException(List exceptions) diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/PlayerAuthException.cs b/Assets/Talo Game Services/Talo/Runtime/Utils/PlayerAuthException.cs index e2f94628..ce58ae66 100644 --- a/Assets/Talo Game Services/Talo/Runtime/Utils/PlayerAuthException.cs +++ b/Assets/Talo Game Services/Talo/Runtime/Utils/PlayerAuthException.cs @@ -23,26 +23,35 @@ public enum PlayerAuthErrorCode { public class PlayerAuthException : Exception { - public PlayerAuthErrorCode ErrorCode => GetErrorCode(); + public PlayerAuthErrorCode ErrorCode { get; } public PlayerAuthException() { + ErrorCode = PlayerAuthErrorCode.API_ERROR; } public PlayerAuthException(string errorCode) : base(errorCode) { + ErrorCode = ParseErrorCode(errorCode); } public PlayerAuthException(string errorCode, Exception inner) : base(errorCode, inner) { + ErrorCode = ParseErrorCode(errorCode); } - private PlayerAuthErrorCode GetErrorCode() + private static PlayerAuthErrorCode ParseErrorCode(string errorCode) { - var errorCode = string.IsNullOrEmpty(Message) ? "API_ERROR" : Message; - return (PlayerAuthErrorCode)Enum.Parse(typeof(PlayerAuthErrorCode), errorCode); + if (string.IsNullOrEmpty(errorCode)) + { + return PlayerAuthErrorCode.API_ERROR; + } + + return Enum.TryParse(errorCode, out PlayerAuthErrorCode code) + ? code + : PlayerAuthErrorCode.API_ERROR; } } } diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/SocketException.cs b/Assets/Talo Game Services/Talo/Runtime/Utils/SocketException.cs index 9268a3ec..af632b34 100644 --- a/Assets/Talo Game Services/Talo/Runtime/Utils/SocketException.cs +++ b/Assets/Talo Game Services/Talo/Runtime/Utils/SocketException.cs @@ -21,29 +21,38 @@ public class SocketException : Exception private readonly SocketError errorData; public string Req => errorData?.req ?? "unknown"; - public SocketErrorCode ErrorCode => GetErrorCode(); + public SocketErrorCode ErrorCode { get; } public string Cause => errorData?.cause ?? ""; public SocketException() { + ErrorCode = SocketErrorCode.API_ERROR; } public SocketException(SocketError errorData) : base(errorData.message) { this.errorData = errorData; + ErrorCode = ParseErrorCode(errorData?.errorCode); } public SocketException(SocketError errorData, Exception inner) : base(errorData.message, inner) { this.errorData = errorData; + ErrorCode = ParseErrorCode(errorData?.errorCode); } - private SocketErrorCode GetErrorCode() + private static SocketErrorCode ParseErrorCode(string errorCode) { - var errorCode = string.IsNullOrEmpty(errorData?.errorCode) ? "API_ERROR" : errorData.errorCode; - return (SocketErrorCode)Enum.Parse(typeof(SocketErrorCode), errorCode); + if (string.IsNullOrEmpty(errorCode)) + { + return SocketErrorCode.API_ERROR; + } + + return Enum.TryParse(errorCode, out SocketErrorCode code) + ? code + : SocketErrorCode.API_ERROR; } } } From 4b21a7ccfc76b37043332b2b9062ee3b0d8be866 Mon Sep 17 00:00:00 2001 From: tudor <7089284+tudddorrr@users.noreply.github.com> Date: Sat, 4 Jul 2026 14:13:03 +0100 Subject: [PATCH 2/2] move exceptions to their own folder --- Assets/Talo Game Services/Talo/Runtime/Exceptions.meta | 8 ++++++++ .../{Utils => Exceptions}/ContinuityReplayException.cs | 0 .../ContinuityReplayException.cs.meta | 0 .../Runtime/{Utils => Exceptions}/IdentifyException.cs | 0 .../{Utils => Exceptions}/IdentifyException.cs.meta | 0 .../Runtime/{Utils => Exceptions}/PlayerAuthException.cs | 0 .../{Utils => Exceptions}/PlayerAuthException.cs.meta | 0 .../Runtime/{Utils => Exceptions}/RequestException.cs | 0 .../{Utils => Exceptions}/RequestException.cs.meta | 0 .../Talo/Runtime/{Utils => Exceptions}/SocketException.cs | 0 .../Runtime/{Utils => Exceptions}/SocketException.cs.meta | 0 unity.slnx | 2 +- 12 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Assets/Talo Game Services/Talo/Runtime/Exceptions.meta rename Assets/Talo Game Services/Talo/Runtime/{Utils => Exceptions}/ContinuityReplayException.cs (100%) rename Assets/Talo Game Services/Talo/Runtime/{Utils => Exceptions}/ContinuityReplayException.cs.meta (100%) rename Assets/Talo Game Services/Talo/Runtime/{Utils => Exceptions}/IdentifyException.cs (100%) rename Assets/Talo Game Services/Talo/Runtime/{Utils => Exceptions}/IdentifyException.cs.meta (100%) rename Assets/Talo Game Services/Talo/Runtime/{Utils => Exceptions}/PlayerAuthException.cs (100%) rename Assets/Talo Game Services/Talo/Runtime/{Utils => Exceptions}/PlayerAuthException.cs.meta (100%) rename Assets/Talo Game Services/Talo/Runtime/{Utils => Exceptions}/RequestException.cs (100%) rename Assets/Talo Game Services/Talo/Runtime/{Utils => Exceptions}/RequestException.cs.meta (100%) rename Assets/Talo Game Services/Talo/Runtime/{Utils => Exceptions}/SocketException.cs (100%) rename Assets/Talo Game Services/Talo/Runtime/{Utils => Exceptions}/SocketException.cs.meta (100%) diff --git a/Assets/Talo Game Services/Talo/Runtime/Exceptions.meta b/Assets/Talo Game Services/Talo/Runtime/Exceptions.meta new file mode 100644 index 00000000..4d68c5a7 --- /dev/null +++ b/Assets/Talo Game Services/Talo/Runtime/Exceptions.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fe7598f29ba824a71a1983bf4801be12 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/ContinuityReplayException.cs b/Assets/Talo Game Services/Talo/Runtime/Exceptions/ContinuityReplayException.cs similarity index 100% rename from Assets/Talo Game Services/Talo/Runtime/Utils/ContinuityReplayException.cs rename to Assets/Talo Game Services/Talo/Runtime/Exceptions/ContinuityReplayException.cs diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/ContinuityReplayException.cs.meta b/Assets/Talo Game Services/Talo/Runtime/Exceptions/ContinuityReplayException.cs.meta similarity index 100% rename from Assets/Talo Game Services/Talo/Runtime/Utils/ContinuityReplayException.cs.meta rename to Assets/Talo Game Services/Talo/Runtime/Exceptions/ContinuityReplayException.cs.meta diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/IdentifyException.cs b/Assets/Talo Game Services/Talo/Runtime/Exceptions/IdentifyException.cs similarity index 100% rename from Assets/Talo Game Services/Talo/Runtime/Utils/IdentifyException.cs rename to Assets/Talo Game Services/Talo/Runtime/Exceptions/IdentifyException.cs diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/IdentifyException.cs.meta b/Assets/Talo Game Services/Talo/Runtime/Exceptions/IdentifyException.cs.meta similarity index 100% rename from Assets/Talo Game Services/Talo/Runtime/Utils/IdentifyException.cs.meta rename to Assets/Talo Game Services/Talo/Runtime/Exceptions/IdentifyException.cs.meta diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/PlayerAuthException.cs b/Assets/Talo Game Services/Talo/Runtime/Exceptions/PlayerAuthException.cs similarity index 100% rename from Assets/Talo Game Services/Talo/Runtime/Utils/PlayerAuthException.cs rename to Assets/Talo Game Services/Talo/Runtime/Exceptions/PlayerAuthException.cs diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/PlayerAuthException.cs.meta b/Assets/Talo Game Services/Talo/Runtime/Exceptions/PlayerAuthException.cs.meta similarity index 100% rename from Assets/Talo Game Services/Talo/Runtime/Utils/PlayerAuthException.cs.meta rename to Assets/Talo Game Services/Talo/Runtime/Exceptions/PlayerAuthException.cs.meta diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/RequestException.cs b/Assets/Talo Game Services/Talo/Runtime/Exceptions/RequestException.cs similarity index 100% rename from Assets/Talo Game Services/Talo/Runtime/Utils/RequestException.cs rename to Assets/Talo Game Services/Talo/Runtime/Exceptions/RequestException.cs diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/RequestException.cs.meta b/Assets/Talo Game Services/Talo/Runtime/Exceptions/RequestException.cs.meta similarity index 100% rename from Assets/Talo Game Services/Talo/Runtime/Utils/RequestException.cs.meta rename to Assets/Talo Game Services/Talo/Runtime/Exceptions/RequestException.cs.meta diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/SocketException.cs b/Assets/Talo Game Services/Talo/Runtime/Exceptions/SocketException.cs similarity index 100% rename from Assets/Talo Game Services/Talo/Runtime/Utils/SocketException.cs rename to Assets/Talo Game Services/Talo/Runtime/Exceptions/SocketException.cs diff --git a/Assets/Talo Game Services/Talo/Runtime/Utils/SocketException.cs.meta b/Assets/Talo Game Services/Talo/Runtime/Exceptions/SocketException.cs.meta similarity index 100% rename from Assets/Talo Game Services/Talo/Runtime/Utils/SocketException.cs.meta rename to Assets/Talo Game Services/Talo/Runtime/Exceptions/SocketException.cs.meta diff --git a/unity.slnx b/unity.slnx index fdbc512e..78ddfab3 100644 --- a/unity.slnx +++ b/unity.slnx @@ -1,7 +1,7 @@  - +