/// <summary> /// Captures synchronous and asynchronous exceptions from the pipeline and generates HTML error responses. /// Full error details are only displayed by default if 'host.AppMode' is set to 'development' in the IAppBuilder.Properties. /// </summary> /// <param name="builder"></param> /// <param name="options"></param> /// <returns></returns> public static IAppBuilder UseErrorPage(this IAppBuilder builder, ErrorPageOptions options) { if (builder == null) { throw new ArgumentNullException("builder"); } string appMode = new AppProperties(builder.Properties).Get<string>(Constants.HostAppMode); bool isDevMode = string.Equals(Constants.DevMode, appMode, StringComparison.Ordinal); return builder.Use<ErrorPageMiddleware>(options, isDevMode); }
/// <summary> /// Initializes a new instance of the <see cref="ErrorPageMiddleware"/> class /// </summary> /// <param name="next"></param> /// <param name="options"></param> /// <param name="isDevMode"></param> public ErrorPageMiddleware(OwinMiddleware next, ErrorPageOptions options, bool isDevMode) : base(next) { if (options == null) { throw new ArgumentNullException("options"); } if (isDevMode) { options.SetDefaultVisibility(isVisible: true); } _options = options; }
/// <summary> /// Initializes a new instance of the <see cref="ErrorPageMiddleware"/> class /// </summary> /// <param name="next"></param> /// <param name="options"></param> /// <param name="isDevMode"></param> public ErrorPageMiddleware(AppFunc next, ErrorPageOptions options, bool isDevMode) { if (next == null) { throw new ArgumentNullException("next"); } if (options == null) { throw new ArgumentNullException("options"); } if (isDevMode) { options.SetDefaultVisibility(isVisible: true); } _next = next; _options = options; }
/// <summary> /// Initializes a new instance of the <see cref="ErrorPageMiddleware"/> class /// </summary> /// <param name="next"></param> /// <param name="options"></param> /// <param name="isDevMode"></param> public ErrorPageMiddleware(AppFunc next, ErrorPageOptions options, ILogger logger, bool isDevMode) { if (next == null) { throw new ArgumentNullException("next"); } if (options == null) { throw new ArgumentNullException("options"); } if (isDevMode) { options.SetDefaultVisibility(isVisible: true); } _next = next; _options = options; _logger = logger; }