Skip to content

Commit c09fa57

Browse files
authored
fix: gracefully handle exceptions in an RPC invoke (#846)
1 parent e409b37 commit c09fa57

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

com.unity.multiplayer.mlapi/Runtime/Messaging/RpcQueue/RpcQueueProcessor.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using Unity.Profiling;
44
using MLAPI.Configuration;
55
using MLAPI.Profiling;
6+
using MLAPI.Logging;
7+
using UnityEngine;
68

79
namespace MLAPI.Messaging
810
{
@@ -60,7 +62,19 @@ public void ProcessReceiveQueue(NetworkUpdateStage currentStage, bool isTesting)
6062

6163
if (!isTesting)
6264
{
63-
m_NetworkManager.InvokeRpc(currentQueueItem);
65+
try
66+
{
67+
m_NetworkManager.InvokeRpc(currentQueueItem);
68+
}
69+
catch (Exception ex)
70+
{
71+
Debug.LogException(ex);
72+
73+
if (NetworkLog.CurrentLogLevel <= LogLevel.Normal)
74+
{
75+
NetworkLog.LogWarning($"A {currentQueueItem.QueueItemType} threw an exception while executing! Please check Unity logs for more information.");
76+
}
77+
}
6478
}
6579

6680
ProfilerStatManager.RpcsQueueProc.Record();

0 commit comments

Comments
 (0)