Browse Source

Preserve stack trace for websocket errors

tags/docs-0.9
Brandon Smith 9 years ago
parent
commit
5b432769fb
3 changed files with 5 additions and 4 deletions
  1. +1
    -1
      src/Discord.Net/DiscordDataSocket.cs
  2. +1
    -1
      src/Discord.Net/DiscordVoiceSocket.cs
  3. +3
    -2
      src/Discord.Net/DiscordWebSocket.cs

+ 1
- 1
src/Discord.Net/DiscordDataSocket.cs View File

@@ -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; }


+ 1
- 1
src/Discord.Net/DiscordVoiceSocket.cs View File

@@ -109,7 +109,7 @@ namespace Discord
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {
throw _disconnectReason;
_disconnectReason.Throw();
} }


SetConnected(); SetConnected();


+ 3
- 2
src/Discord.Net/DiscordWebSocket.cs View File

@@ -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();
} }
} }


Loading…
Cancel
Save