Skip to content

Commit

Permalink
Merge pull request #75 from TaloDev/continuity-replay-exception
Browse files Browse the repository at this point in the history
Add continuity replay exception
  • Loading branch information
tudddorrr authored Sep 16, 2024
2 parents 41ddb93 + eb06517 commit 936e757
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Packages/com.trytalo.talo/Runtime/Utils/ContinuityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public async void ProcessRequests()
if (!HasRequests() || !await Talo.HealthCheck.Ping()) return;

var queue = new List<Request>(_requests.Take(10));
var exceptions = new List<Exception>();

for (var i = 0; i < queue.Count; i++)
{
Expand All @@ -98,7 +99,18 @@ public async void ProcessRequests()
headers.Add(new HttpHeader("X-Talo-Continuity-Timestamp", request.timestamp.ToString()));
}

await _api.Replay(uri, request.method, request.content, headers);
try
{
await _api.Replay(uri, request.method, request.content, headers);
} catch (Exception e)
{
exceptions.Add(e);
}
}

if (exceptions.Count > 0)
{
throw new ContinuityReplayException(exceptions);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;

namespace TaloGameServices
{
public class ContinuityReplayException : Exception
{
private List<Exception> _exceptions;
public List<Exception> Exceptions => _exceptions;

public ContinuityReplayException(List<Exception> exceptions)
: base($"{exceptions.Count} requests failed after being replayed")
{
_exceptions = exceptions;
}

public ContinuityReplayException(List<Exception> exceptions, Exception inner)
: base($"{exceptions.Count} requests failed after being replayed", inner)
{
_exceptions = exceptions;
}
}
}

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

0 comments on commit 936e757

Please sign in to comment.