mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Preserve exception stack trace using ExceptionDispatchInfo
Co-authored-by: Kvarkas <3611964+Kvarkas@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@ using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.Resources.Language;
|
||||
using System.Runtime.Versioning;
|
||||
using mRemoteNG.Security;
|
||||
using System.Runtime.ExceptionServices;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
@@ -22,7 +23,7 @@ namespace mRemoteNG.Connection.Protocol.VNC
|
||||
private VncSharpCore.RemoteDesktop _vnc;
|
||||
private ConnectionInfo _info;
|
||||
private static bool _isConnectionSuccessful;
|
||||
private static Exception _socketexception;
|
||||
private static ExceptionDispatchInfo _socketexception;
|
||||
private static readonly ManualResetEvent TimeoutObject = new(false);
|
||||
private static readonly object _testConnectLock = new();
|
||||
|
||||
@@ -176,7 +177,7 @@ namespace mRemoteNG.Connection.Protocol.VNC
|
||||
// Connection completed but failed - tcpclient will be closed in CallBackMethod's finally block
|
||||
if (_socketexception != null)
|
||||
{
|
||||
throw _socketexception;
|
||||
_socketexception.Throw();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -205,7 +206,7 @@ namespace mRemoteNG.Connection.Protocol.VNC
|
||||
catch (Exception ex)
|
||||
{
|
||||
_isConnectionSuccessful = false;
|
||||
_socketexception = ex;
|
||||
_socketexception = ExceptionDispatchInfo.Capture(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user