From c3dc8cd15a311ab52546599ed439701560916b6c Mon Sep 17 00:00:00 2001 From: Finite Reality Date: Sun, 31 Jul 2016 18:53:04 +0100 Subject: [PATCH] Use async methods and feed exceptions to promise --- .../WebSocket/Entities/Guilds/SocketGuild.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net/WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net/WebSocket/Entities/Guilds/SocketGuild.cs index 3ead0d6a5..e1ed18261 100644 --- a/src/Discord.Net/WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net/WebSocket/Entities/Guilds/SocketGuild.cs @@ -307,8 +307,16 @@ namespace Discord { _audioLock.Release(); } - await audioClient.ConnectAsync(url, CurrentUser.Id, voiceState.VoiceSessionId, token).ConfigureAwait(false); - _audioConnectPromise.TrySetResult(true); + + try + { + await audioClient.ConnectAsync(url, CurrentUser.Id, voiceState.VoiceSessionId, token).ConfigureAwait(false); + await _audioConnectPromise.TrySetResultAsync(true).ConfigureAwait(false); + } + catch(Exception e) + { + await _audioConnectPromise.SetExceptionAsync(e).ConfigureAwait(false); + } } public SocketGuild Clone() => MemberwiseClone() as SocketGuild;