Public class library (3) exception handling class exceptionhandlingutil

Source: Internet
Author: User

Create a configuration file with the following code:

View code

<exceptionHandling>        <exceptionPolicies>            <add name="Default Policy">                <exceptionTypes>                    <add name="All Exceptions" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"                        postHandlingAction="NotifyRethrow">                        <exceptionHandlers>                            <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"                                logCategory="Exception" eventId="100" severity="Error" title="Enterprise Library Exception Handling"                                formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"                                priority="0" />                        </exceptionHandlers>                    </add>                </exceptionTypes>            </add>        </exceptionPolicies>    </exceptionHandling>

The Code is as follows:

Namespace TMAC. utilities {// <summary> // exception handling operation class /// </Summary> public class exceptionhandlingutil {// default policy, consistent with the private const string defaultpolicy = "Default policy" defined in the configuration file "; /// <summary> /// record the exception log /// </Summary> /// <Param name = "ex"> </param> /// <returns> </returns> Public static bool handleexception (exception ex) {return handleexception (ex, defaultpolicy);} public static bool handleexception (exception ex, string Policy) {return exceptionpolicy. handleexception (ex, Policy );}}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.