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
exceptionExceptionThe exception to include in the error.
includeErrorDetailbooltrue if the error should include exception messages; otherwise, false .
contentNegotiatorIContentNegotiatorThe content negotiator to handle content negotiation.
requestHttpRequestMessageThe request message which led to this result.
formattersIEnumerable<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
exceptionExceptionThe exception to include in the error.
controllerApiControllerThe 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
cancellationTokenCancellationToken
Returns
- Task<HttpResponseMessage>
Returns Task<TResult>.