Skip to content

Commit eecfe7e

Browse files
Adding try/catch to LeaveBeforeQuit to make sure that we quit even if exceptions happen (#563)
1 parent afd1dae commit eecfe7e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Assets/BossRoom/Scripts/Shared/ApplicationController.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections;
23
using BossRoom.Scripts.Shared.Net.UnityServices.Auth;
34
using Unity.Multiplayer.Samples.BossRoom.Client;
@@ -6,7 +7,6 @@
67
using Unity.Multiplayer.Samples.BossRoom.Shared.Net.UnityServices.Infrastructure;
78
using Unity.Multiplayer.Samples.BossRoom.Shared.Net.UnityServices.Lobbies;
89
using Unity.Multiplayer.Samples.Utilities;
9-
using Unity.Netcode;
1010
using UnityEngine;
1111
using UnityEngine.SceneManagement;
1212

@@ -88,7 +88,15 @@ private void OnDestroy()
8888
/// </summary>
8989
private IEnumerator LeaveBeforeQuit()
9090
{
91-
m_LobbyServiceFacade.ForceLeaveLobbyAttempt();
91+
// We want to quit anyways, so if anything happens while trying to leave the Lobby, log the exception then carry on
92+
try
93+
{
94+
m_LobbyServiceFacade.ForceLeaveLobbyAttempt();
95+
}
96+
catch (Exception e)
97+
{
98+
Debug.LogError(e.Message);
99+
}
92100
yield return null;
93101
Application.Quit();
94102
}

0 commit comments

Comments
 (0)