Don't TrySetException with a null exception
This commit is contained in:
@@ -113,18 +113,19 @@ namespace Discord.Rpc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task DisconnectAsync()
|
/// <inheritdoc />
|
||||||
|
public Task DisconnectAsync() => DisconnectAsync(null, false);
|
||||||
|
private async Task DisconnectAsync(Exception ex = null, bool isReconnecting = false)
|
||||||
{
|
{
|
||||||
await _connectionLock.WaitAsync().ConfigureAwait(false);
|
if (ex == null)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await DisconnectInternalAsync(null, false).ConfigureAwait(false);
|
if (_connectTask?.TrySetCanceled() ?? false) return;
|
||||||
}
|
}
|
||||||
finally { _connectionLock.Release(); }
|
else
|
||||||
}
|
{
|
||||||
private async Task DisconnectAsync(Exception ex, bool isReconnecting)
|
if (_connectTask?.TrySetException(ex) ?? false) return;
|
||||||
{
|
}
|
||||||
if (_connectTask?.TrySetException(ex) ?? false) return;
|
|
||||||
await _connectionLock.WaitAsync().ConfigureAwait(false);
|
await _connectionLock.WaitAsync().ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -181,19 +181,18 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task DisconnectAsync()
|
public Task DisconnectAsync() => DisconnectAsync(null, false);
|
||||||
|
private async Task DisconnectAsync(Exception ex = null, bool isReconnecting = false)
|
||||||
{
|
{
|
||||||
if (_connectTask?.TrySetCanceled() ?? false) return;
|
if (ex == null)
|
||||||
await _connectionLock.WaitAsync().ConfigureAwait(false);
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await DisconnectInternalAsync(null, false).ConfigureAwait(false);
|
if (_connectTask?.TrySetCanceled() ?? false) return;
|
||||||
}
|
}
|
||||||
finally { _connectionLock.Release(); }
|
else
|
||||||
}
|
{
|
||||||
private async Task DisconnectAsync(Exception ex, bool isReconnecting)
|
if (_connectTask?.TrySetException(ex) ?? false) return;
|
||||||
{
|
}
|
||||||
if (_connectTask?.TrySetException(ex) ?? false) return;
|
|
||||||
await _connectionLock.WaitAsync().ConfigureAwait(false);
|
await _connectionLock.WaitAsync().ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user