NServiceBus.ReceiveStrategy.HandleError C# (CSharp) Method

HandleError() protected method

protected HandleError ( System.Messaging.Message message, string>.Dictionary headers, Exception exception, TransportTransaction transportTransaction, int processingAttempts ) : Task
message System.Messaging.Message
headers string>.Dictionary
exception System.Exception
transportTransaction TransportTransaction
processingAttempts int
return Task
        protected async Task<ErrorHandleResult> HandleError(Message message, Dictionary<string, string> headers, Exception exception, TransportTransaction transportTransaction, int processingAttempts)
        {
            try
            {
                var body = await ReadStream(message.BodyStream).ConfigureAwait(false);
                var errorContext = new ErrorContext(exception, headers, message.Id, body, transportTransaction, processingAttempts);

                return await onError(errorContext).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                criticalError.Raise($"Failed to execute recoverability actions for message `{message.Id}`", ex);

                //best thing we can do is roll the message back if possible
                return ErrorHandleResult.RetryRequired;
            }
        }