public CommonExceptionHandlerMiddleware(
     RequestDelegate next,
     ILoggerFactory loggerFactory,
     DiagnosticSource diagnosticSource,
     IOptions<ExceptionHandlerOptions> options = null
     )
 {
     _next = next;
     if(options == null)
     {
         _options = new ExceptionHandlerOptions();
     }
     else
     {
         _options = options.Value;
     }
     
     _logger = loggerFactory.CreateLogger<CommonExceptionHandlerMiddleware>();
     if (_options.ExceptionHandler == null)
     {
         _options.ExceptionHandler = _next;
     }
     _clearCacheHeadersDelegate = ClearCacheHeaders;
     _diagnosticSource = diagnosticSource;
 }
        public static IApplicationBuilder UseCommonExceptionHandler(this IApplicationBuilder app, ExceptionHandlerOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return app.UseMiddleware<CommonExceptionHandlerMiddleware>(options);
        }
示例#3
0
        public static IApplicationBuilder UseCommonExceptionHandler(this IApplicationBuilder app, ExceptionHandlerOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

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