Partager via


Source Schema for the Exception Handling Application Block

This topic lists the XML elements and attributes used to configure the Exception Handling Application Block. You can manually edit the XML data, but the Enterprise Library Configuration Console greatly simplifies this task. If you choose to manually edit the XML, use the schema information contained in this topic.

The configuration file has the following section-handler declaration.

<configSections>
<section name="exceptionHandling"
         type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings,
               Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" />
</configSections>

The section-handler declaration contains the name of the configuration settings section and the name of the section-handler class that processes configuration data in that section. The name of the configuration settings section is exceptionHandling. The name of the section-handler class is ExceptionHandlingSettings. This class is in the Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration namespace.

exceptionHandling Element

The exceptionHandling element describes the configuration of the Exception Handling Application Block. This element is required. The following sections describe attributes and child elements of the exceptionHandling element.

exceptionPolicies Child Element

The exceptionPolicies element is a child element of the exceptionHandling element. It lists the exception policies that the application can call. This element is optional.

add Child Element

The add element is a child element of the exceptionPolicies element. The add element adds the name of an exception policy. This element is optional. There can be multiple add elements.

Attributes

The following table lists the attributes for the add element.

Attributes

Description

name

The name of the exception policy. The name must be unique within the section. This attribute is required.

exceptionTypes Child Element

The exceptionTypes element is a child of the add element. It lists the exception types that can be handled by the exception policy. This element is optional.

add Child Element

The add element is a child element of the exceptionTypes element. The add element adds the name of an exception type. This element is optional. There can be multiple add elements.

Attributes

The following table lists the attributes for the add element.

Attribute

Description

name

The name of the exception type. The name must be unique within the section. This attribute is required.

type

The type name of a class that derives from the System.Exception class. This attribute is required.

postHandlingAction

Specifies what the exception policy should do after the exception handler is called. Possible values are None, NotifyRethrow, and ThrowNewException. This attribute is required.

exceptionHandlers Child Element

The exceptionHandlers element is a child of the add element. It specifies an exception handler. This element is required.

add Child Element

The add element is a child element of the exceptionHandlers element. The add element adds an exception handler. This element is optional. There can be multiple add elements.

Attributes

The following table lists the attributes for the add element.

Attribute

Description

name

The name of the exception handler. The name must be unique within the section. This attribute is required.

type

The type name of a class that that implements the IExceptionHandler interface. This attribute is required.

exceptionMessage

The message to use with the exception. This attribute is used with the WrapHandler class and the ReplaceHandler class and is required.

wrapExceptionType

The type of the exception that wraps the original exception. It must have a type name of a class that derives from the System.Exception class. This attribute is used with the WrapHandler class and is required.

replaceExceptionType

The type of the exception that replaces the original exception. It must have a type name of a class that derives from the System.Exception class. This attribute is used with the ReplaceHandler class and is required.

logCategory

The category where the exception message should be logged. This attribute is a string. It is used with the LoggingExceptionHandler class and is required.

eventId

The ID number of the exception. This attribute is an integer. It is used with the LoggingExceptionHandler class and is required.

severity

The severity of the exception. This attribute should be one of the values from the TraceEventType enumeration. It is used with the LoggingExceptionHandler class and is required.

title

The title of the log entry. This attribute is a string. It is used with the LoggingExceptionHandler class and is required.

formatterType

The formatter that formats the exception before it is logged. It must have a type name of a class that derives from the ExceptionFormatter class. It is used with the LoggingExceptionHandler class and is required.

priority

The priority of the log entry. This attribute is an integer. It is used with the LoggingExceptionHandler class and is required.

exceptionMessageResourceName

The name of the resource file containing the exception message strings.

exceptionMessageResourceType

This is the resource file type that contains the exception message strings.