// 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.ExceptionHandling; using System.Web.Http.Hosting; using System.Web.Http.WebHost.Routing; namespace System.Web.Http.WebHost { /// Provides the catch blocks used within this assembly. public static class WebHostExceptionCatchBlocks { private static readonly ExceptionContextCatchBlock _httpControllerHandlerBufferContent = new ExceptionContextCatchBlock(typeof(HttpControllerHandler).Name + ".BufferContent", isTopLevel: true, callsHandler: true); private static readonly ExceptionContextCatchBlock _httpControllerHandlerBufferError = new ExceptionContextCatchBlock(typeof(HttpControllerHandler).Name + ".BufferError", isTopLevel: true, callsHandler: false); private static readonly ExceptionContextCatchBlock _httpControllerHandlerComputeContentLength = new ExceptionContextCatchBlock(typeof(HttpControllerHandler).Name + ".ComputeContentLength", isTopLevel: true, callsHandler: false); private static readonly ExceptionContextCatchBlock _httpControllerHandlerStreamContent = new ExceptionContextCatchBlock(typeof(HttpControllerHandler).Name + ".StreamContent", isTopLevel: true, callsHandler: false); private static readonly ExceptionContextCatchBlock _httpWebRoute = new ExceptionContextCatchBlock(typeof(HttpWebRoute).Name, isTopLevel: true, callsHandler: true); /// /// Gets the label for the catch block in /// .WriteBufferedResponseContentAsync. /// /// /// This catch block handles exceptions when writing the under an /// that buffers. /// public static ExceptionContextCatchBlock HttpControllerHandlerBufferContent { get { return _httpControllerHandlerBufferContent; } } /// /// Gets the label for the catch block in .WriteErrorResponseContentAsync. /// /// /// This catch block handles exceptions when writing the of the error response itself /// (after or ). /// public static ExceptionContextCatchBlock HttpControllerHandlerBufferError { get { return _httpControllerHandlerBufferError; } } /// /// Gets the label for the catch block in .ComputeContentLength. /// /// /// This catch block handles exceptions when calling . /// public static ExceptionContextCatchBlock HttpControllerHandlerComputeContentLength { get { return _httpControllerHandlerComputeContentLength; } } /// /// Gets the label for the catch block in /// .WriteStreamedResponseContentAsync. /// /// /// This catch block handles exceptions when writing the under an /// that does not buffer. /// public static ExceptionContextCatchBlock HttpControllerHandlerStreamContent { get { return _httpControllerHandlerStreamContent; } } /// Gets the label for the catch block in .GetRouteData. public static ExceptionContextCatchBlock HttpWebRoute { get { return _httpWebRoute; } } } }