Skip to content

Commit

Permalink
add exception handle
Browse files Browse the repository at this point in the history
  • Loading branch information
jonny-jeahyunchoi committed Jan 2, 2025
1 parent eaa4c91 commit aa203ec
Showing 1 changed file with 49 additions and 41 deletions.
90 changes: 49 additions & 41 deletions nekoyume/Assets/_Scripts/Blockchain/ActionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -934,52 +934,60 @@ public IObservable<ActionEvaluation<BattleArena>> BattleArena(
int ticket
)
{
var action = new BattleArena
try
{
myAvatarAddress = States.Instance.CurrentAvatarState.address,
enemyAvatarAddress = enemyAvatarAddress,
costumes = costumes,
equipments = equipments,
runeInfos = runeInfos,
championshipId = championshipId,
round = round,
ticket = ticket
};

var sentryTrace = Analyzer.Instance.Track("Unity/BattleArena",
new Dictionary<string, Value>()
var action = new BattleArena
{
["championshipId"] = championshipId,
["round"] = round,
["enemyAvatarAddress"] = enemyAvatarAddress.ToString(),
["AvatarAddress"] = States.Instance.CurrentAvatarState.address.ToString(),
["AgentAddress"] = States.Instance.AgentState.address.ToString()
}, true);

var evt = new AirbridgeEvent("BattleArena");
evt.SetValue(championshipId);
evt.AddCustomAttribute("round", round);
evt.AddCustomAttribute("enemy-avatar-address", enemyAvatarAddress.ToString());
evt.AddCustomAttribute("agent-address", States.Instance.CurrentAvatarState.address.ToString());
evt.AddCustomAttribute("avatar-address", States.Instance.AgentState.address.ToString());
AirbridgeUnity.TrackEvent(evt);
myAvatarAddress = States.Instance.CurrentAvatarState.address,
enemyAvatarAddress = enemyAvatarAddress,
costumes = costumes,
equipments = equipments,
runeInfos = runeInfos,
championshipId = championshipId,
round = round,
ticket = ticket
};

var sentryTrace = Analyzer.Instance.Track("Unity/BattleArena",
new Dictionary<string, Value>()
{
["championshipId"] = championshipId,
["round"] = round,
["enemyAvatarAddress"] = enemyAvatarAddress.ToString(),
["AvatarAddress"] = States.Instance.CurrentAvatarState.address.ToString(),
["AgentAddress"] = States.Instance.AgentState.address.ToString()
}, true);

var evt = new AirbridgeEvent("BattleArena");
evt.SetValue(championshipId);
evt.AddCustomAttribute("round", round);
evt.AddCustomAttribute("enemy-avatar-address", enemyAvatarAddress.ToString());
evt.AddCustomAttribute("agent-address", States.Instance.CurrentAvatarState.address.ToString());
evt.AddCustomAttribute("avatar-address", States.Instance.AgentState.address.ToString());
AirbridgeUnity.TrackEvent(evt);

ProcessAction(action);
_lastBattleActionId = action.Id;
return _agent.ActionRenderer.EveryRender<BattleArena>()
.Timeout(ActionTimeout)
.Where(eval => eval.Action.Id.Equals(action.Id))
.First()
.ObserveOnMainThread()
.DoOnError(e =>
{
if (_lastBattleActionId == action.Id)
ProcessAction(action);
_lastBattleActionId = action.Id;
return _agent.ActionRenderer.EveryRender<BattleArena>()
.Timeout(ActionTimeout)
.Where(eval => eval.Action.Id.Equals(action.Id))
.First()
.ObserveOnMainThread()
.DoOnError(e =>
{
_lastBattleActionId = null;
}
if (_lastBattleActionId == action.Id)
{
_lastBattleActionId = null;
}

Game.Game.BackToMainAsync(HandleException(action.Id, e)).Forget();
}).Finally(() => Analyzer.Instance.FinishTrace(sentryTrace));
Game.Game.BackToMainAsync(HandleException(action.Id, e)).Forget();
}).Finally(() => Analyzer.Instance.FinishTrace(sentryTrace));
}
catch (Exception e)
{
Game.Game.BackToMainAsync(e).Forget();
return null;
}
}

public IObservable<ActionEvaluation<PatchTableSheet>> PatchTableSheet(
Expand Down

0 comments on commit aa203ec

Please sign in to comment.