Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Assets/Talo Game Services/Talo/Runtime/Exceptions.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace TaloGameServices
{
public class ContinuityReplayException : Exception
{
private List<Exception> _exceptions;
private readonly List<Exception> _exceptions;
public List<Exception> Exceptions => _exceptions;

public ContinuityReplayException(List<Exception> exceptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
2 changes: 1 addition & 1 deletion unity.slnx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Solution>
<Project Path="Talo.Runtime.csproj" />
<Project Path="Assembly-CSharp.csproj" />
<Project Path="asset-store-tools-editor.csproj" />
<Project Path="Talo.Runtime.csproj" />
<Project Path="Talo.Tests.csproj" />
<Project Path="MikeSchweitzer.WebSocket.csproj" />
<Project Path="Assembly-CSharp-Editor.csproj" />
Expand Down
Loading