Skip to content

Commit

Permalink
Preserve user's exception stack trace in MemoryBus implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Tautvydas Eidietis <tautvydas.e@gmail.com>
  • Loading branch information
Spragalas authored and zarusz committed Aug 9, 2023
1 parent 606a4a7 commit 8a96558
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/SlimMessageBus.Host.Memory/MemoryMessageBus.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace SlimMessageBus.Host.Memory;

using System.Runtime.ExceptionServices;

/// <summary>
/// In-memory message bus <see cref="IMessageBus"/> implementation to use for in process message passing.
/// </summary>
Expand Down Expand Up @@ -106,8 +108,9 @@ private async Task<TResponseMessage> ProduceInternal<TResponseMessage>(object me
var (exception, _, response, _) = await messageProcessor.ProcessMessage(transportMessage, messageHeadersReadOnly, cancellationToken, currentServiceProvider);
if (exception != null)
{

// We want to pass the same exception to the sender as it happened in the handler/consumer
throw exception;
ExceptionDispatchInfo.Capture(exception).Throw();
}

return (TResponseMessage)response;
Expand Down

0 comments on commit 8a96558

Please sign in to comment.