public static IApplicationBuilder WithConventions(this IApplicationBuilder app, Action <ExceptionHandlerConfiguration> configuration)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var opts = new ExceptionHandlerOptions();

            opts.SetHandler(configuration);

            return(app.UseExceptionHandler(opts));
        }
Ejemplo n.º 2
0
        public static IApplicationBuilder UseGlobalExceptionHandler(this IApplicationBuilder app, Action <ExceptionHandlerConfiguration> configuration)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var opts = new ExceptionHandlerOptions {
                ExceptionHandler = ctx => Task.CompletedTask
            };

            opts.SetHandler(configuration);

            return(app.UseExceptionHandler(opts));
        }