public ExceptionTransformationMiddleware(RequestDelegate next, ExceptionTransformationOptions options, ILoggerFactory loggerFactory)
 {
     _clearCacheHeadersDelegate = ClearCacheHeaders;
     _logger = loggerFactory.CreateLogger<ExceptionTransformationMiddleware>();
     _next = next;
     _options = options;
 }
        /// <summary>
        /// Adds middleware to the pipeline that will catch exceptions, log them, and set the status code on the response.
        /// The status code of the response will not be altered is the response has already started.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseExceptionTransformations(this IApplicationBuilder app, ExceptionTransformationOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return app.UseMiddleware<ExceptionTransformationMiddleware>(options);
        }