From b8fa464125ebffeef079f122eb68653bdd9dd81a Mon Sep 17 00:00:00 2001 From: Paulo Date: Fri, 10 Jul 2020 01:13:01 -0300 Subject: [PATCH] fix: Stop TaskCanceledException from bubbling up (#1580) --- src/Discord.Net.WebSocket/ConnectionManager.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Discord.Net.WebSocket/ConnectionManager.cs b/src/Discord.Net.WebSocket/ConnectionManager.cs index 8c9c743cb..e009674e7 100644 --- a/src/Discord.Net.WebSocket/ConnectionManager.cs +++ b/src/Discord.Net.WebSocket/ConnectionManager.cs @@ -141,7 +141,16 @@ namespace Discord catch (OperationCanceledException) { } }); - await _onConnecting().ConfigureAwait(false); + try + { + await _onConnecting().ConfigureAwait(false); + } + catch (TaskCanceledException ex) + { + Exception innerEx = ex.InnerException ?? new OperationCanceledException("Failed to connect."); + Error(innerEx); + throw innerEx; + } await _logger.InfoAsync("Connected").ConfigureAwait(false); State = ConnectionState.Connected;