Example #1
0
        /// <summary>
        /// Captures <see cref="Exception"/> instances from the pipeline and generates error responses.
        /// </summary>
        /// <param name="app">The <see cref="ServerOptions"/> instance this method extends.</param>
        /// <param name="options">The <see cref="StatusCodePagesOptions"/> used to configure the middleware.</param>
        public static void UseStatusCodePages(this ServerOptions app, StatusCodePagesOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

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

            app.UseMiddleware(new StatusCodePagesMiddleware(options));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DeveloperExceptionPageMiddleware"/> class.
        /// </summary>
        /// <param name="options">The options for configuring the middleware.</param>
        public StatusCodePagesMiddleware(StatusCodePagesOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _options = options;

            if (_options.Handle == null)
            {
                throw new ArgumentException("Missing options.HandleAsync implementation.");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DeveloperExceptionPageMiddleware"/> class.
 /// </summary>
 public StatusCodePagesMiddleware()
 {
     _options = new StatusCodePagesOptions();
 }
Example #4
0
        /// <summary>
        /// Captures <see cref="Exception"/> instances from the pipeline and generates error responses.
        /// </summary>
        /// <param name="app">The <see cref="IApplicationBuilder"/> instance this method extends.</param>
        /// <param name="options">The <see cref="StatusCodePagesOptions"/> used to configure the middleware.</param>
        public static IApplicationBuilder UseStatusCodePages(this IApplicationBuilder app, StatusCodePagesOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

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

            return(app.UseMiddleware(typeof(StatusCodePagesMiddleware), options));
        }