Skip to content

Commit 3c9a905

Browse files
fix: silencing errors that are not errors [MTT-2930] [MTT-3249] (#597)
* Preventing RemovePlayerFromLobby from throwing PlayerNotFoundException * Messages for guid not found in SessionManager now are simple logs instead of errors for Get methods
1 parent 8b34f12 commit 3c9a905

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Assets/BossRoom/Scripts/Shared/Net/UnityServices/Lobbies/LobbyAPIInterface.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,15 @@ public async Task<Lobby> QuickJoinLobby(string requesterUasId, Dictionary<string
115115

116116
public async Task RemovePlayerFromLobby(string requesterUasId, string lobbyId)
117117
{
118-
await ExceptionHandling(Lobbies.Instance.RemovePlayerAsync(lobbyId, requesterUasId));
118+
try
119+
{
120+
await ExceptionHandling(Lobbies.Instance.RemovePlayerAsync(lobbyId, requesterUasId));
121+
}
122+
catch (LobbyServiceException e)
123+
when (e is {Reason: LobbyExceptionReason.PlayerNotFound})
124+
{
125+
// If Player is not found, they have already left the lobby or have been kicked out. No need to throw here
126+
}
119127
}
120128

121129
public async Task<QueryResponse> QueryAllLobbies()

Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public string GetPlayerId(ulong clientId)
142142
return playerId;
143143
}
144144

145-
Debug.LogError($"No client player ID found mapped to the given client ID: {clientId}");
145+
Debug.Log($"No client player ID found mapped to the given client ID: {clientId}");
146146
return null;
147147
}
148148

@@ -160,7 +160,7 @@ public string GetPlayerId(ulong clientId)
160160
return GetPlayerData(playerId);
161161
}
162162

163-
Debug.LogError($"No client player ID found mapped to the given client ID: {clientId}");
163+
Debug.Log($"No client player ID found mapped to the given client ID: {clientId}");
164164
return null;
165165
}
166166

@@ -176,7 +176,7 @@ public string GetPlayerId(ulong clientId)
176176
return data;
177177
}
178178

179-
Debug.LogError($"No PlayerData of matching player ID found: {playerId}");
179+
Debug.Log($"No PlayerData of matching player ID found: {playerId}");
180180
return null;
181181
}
182182

0 commit comments

Comments
 (0)