Skip to content

Commit

Permalink
Merge pull request #850 from stebet/preserveStacktraces
Browse files Browse the repository at this point in the history
Fixing rethrown exceptions to properly preserve stackframes.
  • Loading branch information
michaelklishin authored May 26, 2020
2 parents 85729ce + b4fb1b3 commit 81cfa56
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions projects/RabbitMQ.Client/client/impl/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ public void Close(ShutdownEventArgs reason, bool abort, TimeSpan timeout)
// Wait for CloseOk in the MainLoop
_session0.Transmit(ConnectionCloseWrapper(reason.ReplyCode, reason.ReplyText));
}
catch (AlreadyClosedException ace)
catch (AlreadyClosedException)
{
if (!abort)
{
throw ace;
throw;
}
}
#pragma warning disable 0168
Expand All @@ -330,7 +330,7 @@ public void Close(ShutdownEventArgs reason, bool abort, TimeSpan timeout)
{
if (!abort)
{
throw ioe;
throw;
}
else
{
Expand Down
8 changes: 5 additions & 3 deletions projects/RabbitMQ.Client/client/impl/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
using System.Buffers;
using System.IO;
using System.Net.Sockets;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using RabbitMQ.Client.Exceptions;
using RabbitMQ.Client.Framing;
Expand Down Expand Up @@ -228,7 +229,7 @@ private static void ProcessProtocolHeader(Stream reader)

internal static InboundFrame ReadFrom(Stream reader)
{
int type;
int type = default;

try
{
Expand All @@ -247,9 +248,10 @@ internal static InboundFrame ReadFrom(Stream reader)
!(ioe.InnerException is SocketException) ||
((SocketException)ioe.InnerException).SocketErrorCode != SocketError.TimedOut)
{
throw ioe;
throw;
}
throw ioe.InnerException;

ExceptionDispatchInfo.Capture(ioe.InnerException).Throw();
}

if (type == 'A')
Expand Down
4 changes: 2 additions & 2 deletions projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ private ITcpClient ConnectUsingAddressFamily(AmqpTcpEndpoint endpoint,
ConnectOrFail(socket, endpoint, timeout);
return socket;
}
catch (ConnectFailureException e)
catch (ConnectFailureException)
{
socket.Dispose();
throw e;
throw;
}
}

Expand Down
4 changes: 2 additions & 2 deletions projects/Unit/Fixtures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ private Process ExecRabbitMqCtlUsingDocker(string args, string dockerMachineName
catch (Exception e)
{
ReportExecFailure("rabbitmqctl", args, e.Message);
throw e;
throw;
}
}

Expand Down Expand Up @@ -556,7 +556,7 @@ internal Process ExecCommand(string ctl, string args, string changeDirTo)
catch (Exception e)
{
ReportExecFailure(cmd, args, e.Message);
throw e;
throw;
}
}

Expand Down

0 comments on commit 81cfa56

Please sign in to comment.