Class ExceptionResult
Represents an action result that returns a InternalServerError response and performs content negotiation on an HttpError based on an Exception.
public class ExceptionResult : IHttpActionResult
- Inheritance
-
ExceptionResult
- Implements
- Inherited Members
Constructors
ExceptionResult(Exception, bool, IContentNegotiator, HttpRequestMessage, IEnumerable<MediaTypeFormatter>)
Initializes a new instance of the ExceptionResult class.
public ExceptionResult(Exception exception, bool includeErrorDetail, IContentNegotiator contentNegotiator, HttpRequestMessage request, IEnumerable<MediaTypeFormatter> formatters)
Parameters
exception
ExceptionThe exception to include in the error.
includeErrorDetail
booltrue if the error should include exception messages; otherwise, false .
contentNegotiator
IContentNegotiatorThe content negotiator to handle content negotiation.
request
HttpRequestMessageThe request message which led to this result.
formatters
IEnumerable<MediaTypeFormatter>The formatters to use to negotiate and format the content.
ExceptionResult(Exception, ApiController)
Initializes a new instance of the ExceptionResult class.
public ExceptionResult(Exception exception, ApiController controller)
Parameters
exception
ExceptionThe exception to include in the error.
controller
ApiControllerThe controller from which to obtain the dependencies needed for execution.
Properties
ContentNegotiator
Gets the content negotiator to handle content negotiation.
public IContentNegotiator ContentNegotiator { get; }
Property Value
- IContentNegotiator
Returns System.Net.Http.Formatting.IContentNegotiator.
Exception
Gets the exception to include in the error.
public Exception Exception { get; }
Property Value
Formatters
Gets the formatters to use to negotiate and format the content.
public IEnumerable<MediaTypeFormatter> Formatters { get; }
Property Value
- IEnumerable<MediaTypeFormatter>
Returns IEnumerable<T>.
IncludeErrorDetail
Gets a value indicating whether the error should include exception messages.
public bool IncludeErrorDetail { get; }
Property Value
Request
Gets the request message which led to this result.
public HttpRequestMessage Request { get; }
Property Value
- HttpRequestMessage
Returns HttpRequestMessage.
Methods
ExecuteAsync(CancellationToken)
public virtual Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationToken
Returns
- Task<HttpResponseMessage>
Returns Task<TResult>.