// 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.Net.Http;
using System.Web.Http.Controllers;
namespace System.Web.Http.ExceptionHandling
{
/// Represents the context within which unhandled exception handling occurs.
public class ExceptionHandlerContext
{
private readonly ExceptionContext _exceptionContext;
/// Initializes a new instance of the class.
/// The exception context.
public ExceptionHandlerContext(ExceptionContext exceptionContext)
{
if (exceptionContext == null)
{
throw new ArgumentNullException("exceptionContext");
}
_exceptionContext = exceptionContext;
}
/// Gets the exception context providing the exception and related data.
public ExceptionContext ExceptionContext
{
get { return _exceptionContext; }
}
/// Gets or sets the result providing the response message when the exception is handled.
///
/// If this value is , the exception is left unhandled and will be re-thrown.
///
public IHttpActionResult Result { get; set; }
/// Gets the exception caught.
public Exception Exception
{
get { return _exceptionContext.Exception; }
}
/// Gets the catch block in which the exception was caught.
public ExceptionContextCatchBlock CatchBlock
{
get { return _exceptionContext.CatchBlock; }
}
/// Gets the request being processed when the exception was caught.
public HttpRequestMessage Request
{
get { return _exceptionContext.Request; }
}
/// Gets the request context in which the exception occurred.
public HttpRequestContext RequestContext
{
get { return _exceptionContext.RequestContext; }
}
}
}