diff --git a/Obsidian/Server.cs b/Obsidian/Server.cs index bb9f1aa1..40930878 100644 --- a/Obsidian/Server.cs +++ b/Obsidian/Server.cs @@ -394,13 +394,19 @@ async Task ExecuteAsync(Client client) { // Ignore. } + catch (Exception exception) + { + _logger.LogError("Unexpected exception from client {Identifier}: {Message}", client.id, exception.Message); + } + finally + { + _clients.TryRemove(client); - _clients.TryRemove(client); - - if (client.Player is not null) - _ = OnlinePlayers.TryRemove(client.Player.Uuid, out _); + if (client.Player is not null) + _ = OnlinePlayers.TryRemove(client.Player.Uuid, out _); - client.Dispose(); + client.Dispose(); + } } }