/// <summary>
        /// Handles the execution exception.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public async Task <MessagingContext> HandleExecutionException(Exception exception, MessagingContext context)
        {
            Logger.Error(exception.Message);

            using (DatastoreContext db = _createContext())
            {
                await db.TransactionalAsync(async ctx =>
                {
                    var repository = new DatastoreRepository(ctx);
                    var service    = new ExceptionService(_configuration, repository, _bodyStore);

                    InException entity =
                        context.SubmitMessage != null
                            ? await service.InsertIncomingSubmitExceptionAsync(exception, context.SubmitMessage, context.ReceivingPMode)
                            : await service.InsertIncomingAS4MessageExceptionAsync(exception, context.EbmsMessageId, context.ReceivingPMode);

                    await ctx.SaveChangesAsync();

                    service.InsertRelatedRetryReliability(entity, context.ReceivingPMode?.ExceptionHandling?.Reliability);
                    await ctx.SaveChangesAsync();
                });
            }

            return(new MessagingContext(exception)
            {
                ErrorResult = context.ErrorResult
            });
        }