Preserve stack trace for websocket errors
This commit is contained in:
@@ -42,7 +42,7 @@ namespace Discord
|
|||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
throw _disconnectReason;// ?? new Exception("Operation was cancelled");
|
_disconnectReason.Throw();
|
||||||
}
|
}
|
||||||
try { _connectWaitOnLogin2.Wait(cancelToken); } //Waiting on READY handler
|
try { _connectWaitOnLogin2.Wait(cancelToken); } //Waiting on READY handler
|
||||||
catch (OperationCanceledException) { return; }
|
catch (OperationCanceledException) { return; }
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ namespace Discord
|
|||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
throw _disconnectReason;
|
_disconnectReason.Throw();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetConnected();
|
SetConnected();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Net.WebSockets;
|
using System.Net.WebSockets;
|
||||||
|
using System.Runtime.ExceptionServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -23,7 +24,7 @@ namespace Discord
|
|||||||
protected CancellationTokenSource _disconnectToken;
|
protected CancellationTokenSource _disconnectToken;
|
||||||
protected string _host;
|
protected string _host;
|
||||||
protected int _timeout, _heartbeatInterval;
|
protected int _timeout, _heartbeatInterval;
|
||||||
protected Exception _disconnectReason;
|
protected ExceptionDispatchInfo _disconnectReason;
|
||||||
private ClientWebSocket _webSocket;
|
private ClientWebSocket _webSocket;
|
||||||
private DateTime _lastHeartbeat;
|
private DateTime _lastHeartbeat;
|
||||||
private Task _task;
|
private Task _task;
|
||||||
@@ -103,7 +104,7 @@ namespace Discord
|
|||||||
if (_disconnectReason == null)
|
if (_disconnectReason == null)
|
||||||
{
|
{
|
||||||
_wasDisconnectUnexpected = isUnexpected;
|
_wasDisconnectUnexpected = isUnexpected;
|
||||||
_disconnectReason = ex;
|
_disconnectReason = ExceptionDispatchInfo.Capture(ex);
|
||||||
_disconnectToken.Cancel();
|
_disconnectToken.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user