Handle() public method

Handles the specified message.
An error has occurred in the error handling code An unhanded exception has occurred while processing a message
public Handle ( IReceivedMessageInternal message, IMessageContext context, Exception exception ) : void
message IReceivedMessageInternal The message.
context IMessageContext The context.
exception System.Exception The exception.
return void
        /// <summary>
        /// Handles processing the specified message with the context
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="transportMessage">The transport message.</param>
        /// <returns></returns>
        public async Task HandleAsync(IMessageContext context, IReceivedMessageInternal transportMessage)
        {
            using (var heartBeat = _heartBeatWorkerFactory.Create(context))
            {
                try
                {
                    await _methodToRun.HandleAsync(transportMessage, context.WorkerNotification).ConfigureAwait(false);

                    _commitMessage.Commit(context);
                }
                // ReSharper disable once UncatchableException
                catch (ThreadAbortException)
                {
                    heartBeat.Stop();
                    throw;
                }
                catch (OperationCanceledException)
                {
                    heartBeat.Stop();
                    throw;
                }
                catch (Exception exception)
                {
                    heartBeat.Stop();
                    _messageExceptionHandler.Handle(transportMessage, context, exception.InnerException ?? exception);
                }
            }
        }
 /// <summary>
 /// Handles processing the specified message with the context
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="transportMessage">The transport message.</param>
 /// <returns></returns>
 public bool Handle(IMessageContext context, IReceivedMessageInternal transportMessage)
 {
     using (var heartBeat = _heartBeatWorkerFactory.Create(context))
     {
         try
         {
             _methodToRun.Handle(transportMessage, context.WorkerNotification);
             _commitMessage.Commit(context);
             return(true);
         }
         // ReSharper disable once UncatchableException
         catch (ThreadAbortException)
         {
             heartBeat.Stop();
             throw;
         }
         catch (OperationCanceledException)
         {
             heartBeat.Stop();
             throw;
         }
         catch (Exception exception)
         {
             heartBeat.Stop();
             _messageExceptionHandler.Handle(transportMessage, context, exception);
         }
     }
     return(false);
 }
        public void Message_Handled_Exception_Throws_Exception()
        {
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
            IReceiveMessagesError error = fixture.Create<ReceiveMessagesErrorWillCrash>();
            fixture.Inject(error);
            var test = new MessageExceptionHandler(error, Substitute.For<ILogFactory>());

            var message = fixture.Create<IReceivedMessageInternal>();
            var context = fixture.Create<IMessageContext>();
            var exception = new Exception();

            Assert.Throws<DotNetWorkQueueException>(
            delegate
            {
                test.Handle(message, context, exception);
            });
        }