// 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;
using System.Threading.Tasks;
namespace System.Web.Http.ExceptionHandling
{
/// Defines an unhandled exception handler.
///
/// An unhandled exception handler can either handle the exception (by providing a response) or allow it to
/// propagate (by providing no response).
///
public interface IExceptionHandler
{
///
/// Process an unhandled exception, either allowing it to propagate or handling it by providing a response
/// message to return instead.
///
/// The exception handler context.
/// The token to monitor for cancellation requests.
/// A task representing the asynchronous exception handling operation.
///
///
/// The exception handler either handles the exception or allows it to propagate. An exception is handled by
/// setting , which provides the response message to return in
/// place of the exception thrown. If is
/// , the exception remains unhandled, and the exception will continue to propagate up
/// the call stack.
///
///
/// If the exception propagates when is
/// , the host will see the exception thrown. If the exception propagates when
/// is , another catch block within
/// Web API will be the next to see the exception, and the exception handler will be called again to make a
/// decision at that point.
///
///
Task HandleAsync(ExceptionHandlerContext context, CancellationToken cancellationToken);
}
}