// 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.Diagnostics; namespace System.Web.Http.ExceptionHandling { /// Represents the catch block location for an . [DebuggerDisplay("Name: {Name}, IsTopLevel: {IsTopLevel}")] public class ExceptionContextCatchBlock { private readonly string _name; private readonly bool _isTopLevel; private readonly bool _callsHandler; /// /// Initializes a new instance of with the values provided. /// /// The label for the catch block where the exception was caught. /// /// A value indicating whether the catch block where the exception was caught is the last one before the host. /// /// /// A value indicating whether exceptions in the catch block can be handled after they are logged. /// /// /// To compare an exception catch block with a well-known value, see classes like /// for the specific objects to use. /// This constructor is only intended for use within static classes that define such well-known catch blocks. /// public ExceptionContextCatchBlock(string name, bool isTopLevel, bool callsHandler) { if (name == null) { throw new ArgumentNullException("name"); } _name = name; _isTopLevel = isTopLevel; _callsHandler = callsHandler; } /// Gets a label for the catch block in which the exception was caught. public string Name { get { return _name; } } /// /// Gets a value indicating whether the catch block where the exception was caught is the last one before the /// host. /// public bool IsTopLevel { get { return _isTopLevel; } } /// /// Gets a value indicating whether exceptions in the catch block can be handled after they are logged. /// /// /// /// Some exceptions are caught after a response is already partially sent, which prevents sending a new /// response to handle the exception. In such cases, will be called to log the /// exception, but the will not be called. /// /// /// If this value is , exceptions from this catch block will be provided to both /// and . If this value is /// see langword="false"/>, exceptions from this catch block cannot be handled and will only be provided to /// . /// /// public bool CallsHandler { get { return _callsHandler; } } /// public override string ToString() { return _name; } } }