// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace System.Web.Http { /// /// An action result that returns a response and /// performs content negotiation on an based on an . /// public class ExceptionResult : ObjectResult { /// Initializes a new instance of the class. /// The exception to include in the error. /// /// if the error should include exception messages; otherwise, . /// public ExceptionResult(Exception exception, bool includeErrorDetail) : base(new HttpError(exception, includeErrorDetail)) { Exception = exception; IncludeErrorDetail = includeErrorDetail; } /// /// Gets the exception to include in the error. /// public Exception Exception { get; private set; } /// /// Gets a value indicating whether the error should include exception messages. /// public bool IncludeErrorDetail { get; private set; } /// public override Task ExecuteResultAsync(ActionContext context) { context.HttpContext.Response.StatusCode = StatusCodes.Status500InternalServerError; return base.ExecuteResultAsync(context); } } }