Use ExceptionDispatchInfo in more places (#1182)

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
This commit is contained in:
Rob Hague
2023-09-23 16:20:59 +01:00
committed by GitHub
parent 18e6673031
commit aade354748
5 changed files with 19 additions and 9 deletions
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Threading;
using Renci.SshNet.Abstractions;
@@ -78,7 +79,7 @@ namespace Renci.SshNet
if (_exception != null)
{
throw _exception;
ExceptionDispatchInfo.Capture(_exception).Throw();
}
return _authenticationResult;
@@ -1,4 +1,5 @@
using System;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading;
@@ -114,7 +115,7 @@ namespace Renci.SshNet
if (_exception != null)
{
throw _exception;
ExceptionDispatchInfo.Capture(_exception).Throw();
}
return _authenticationResult;
+3 -2
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.ExceptionServices;
using System.Threading;
using Renci.SshNet.Abstractions;
@@ -80,7 +81,7 @@ namespace Renci.SshNet.Sftp
if (_exception is not null)
{
throw _exception;
ExceptionDispatchInfo.Capture(_exception).Throw();
}
if (_isEndOfFileRead)
@@ -102,7 +103,7 @@ namespace Renci.SshNet.Sftp
// throw when exception occured in read-ahead, or the current instance is already disposed
if (_exception != null)
{
throw _exception;
ExceptionDispatchInfo.Capture(_exception).Throw();
}
var data = nextChunk.Data;
+3 -1
View File
@@ -1,6 +1,7 @@
using System;
using System.Globalization;
using System.IO;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading;
@@ -483,7 +484,8 @@ namespace Renci.SshNet
switch (signaledElement)
{
case 0:
throw _exception;
ExceptionDispatchInfo.Capture(_exception).Throw();
break;
case 1:
// Specified waithandle was signaled
break;
+9 -4
View File
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using System.Runtime.ExceptionServices;
using System.Threading;
using Renci.SshNet.Abstractions;
@@ -241,7 +242,8 @@ namespace Renci.SshNet
switch (result)
{
case 0:
throw _exception;
ExceptionDispatchInfo.Capture(_exception).Throw();
break;
case 1:
throw new SshException("Connection was closed by the server.");
case 2:
@@ -286,7 +288,8 @@ namespace Renci.SshNet
switch (result)
{
case 0:
throw _exception;
ExceptionDispatchInfo.Capture(_exception).Throw();
return false; // unreached
case 1:
throw new SshException("Connection was closed by the server.");
case 2:
@@ -340,7 +343,8 @@ namespace Renci.SshNet
switch (result)
{
case 0:
throw _exception;
ExceptionDispatchInfo.Capture(_exception).Throw();
return -1; // unreached
case 1:
throw new SshException("Connection was closed by the server.");
case 2:
@@ -377,7 +381,8 @@ namespace Renci.SshNet
switch (result)
{
case 0:
throw _exception;
ExceptionDispatchInfo.Capture(_exception).Throw();
return -1; // unreached
case 1:
throw new SshException("Connection was closed by the server.");
case 2: