// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. using System; using Microsoft.AspNet.Abstractions; using Microsoft.AspNet.Diagnostics; namespace Microsoft.AspNet { /// /// IBuilder extension methods for the ErrorPageMiddleware. /// public static class ErrorPageExtensions { /// /// 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 IBuilder.Properties. /// /// /// public static IBuilder UseErrorPage(this IBuilder builder) { if (builder == null) { throw new ArgumentNullException("builder"); } return builder.UseErrorPage(new ErrorPageOptions()); } /// /// 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 IBuilder.Properties. /// /// /// /// public static IBuilder UseErrorPage(this IBuilder builder, ErrorPageOptions options) { if (builder == null) { throw new ArgumentNullException("builder"); } /* TODO: Development, Staging, or Production string appMode = new AppProperties(builder.Properties).Get(Constants.HostAppMode); bool isDevMode = string.Equals(Constants.DevMode, appMode, StringComparison.Ordinal);*/ bool isDevMode = true; return builder.Use(next => new ErrorPageMiddleware(next, options, isDevMode).Invoke); } } }