Structured exception handling (iii) system-level exceptions and application-level exceptions

Source: Internet
Author: User

I. System-level exceptions

1. Quasi-de: A system exception caused by the. NET platform should be called. These exceptions are considered as unrecoverable fatal errors.

2. system exceptions are directly derived from the base class named system. systemexception, which is derived from system. Exception.

Systemexception does not add any function except a set of custom constructors.

Public class systemexception: exception

{

// Constructors

}

3. When an exception type is derived from system. systemexception, we can determine that the entity that causes the exception is the. NET Runtime Library rather than the library code being executed.

You can useIs keywordTo verify this conclusion:

NullReferenceException nullRefEx = new NullReferenceException();Console.WriteLine("NullREferenceException is a SystemException? : {0}", nullRefEx is SystemException);

2. Application-level exceptions
1. Custom exceptions should be derived from the system. applicationexception type:

Public class applicationexception: exception

{

// Constructors

}

Just like a system exception, an application exception does not define any other member outside a group of constructors.

2. In terms of function, the only purpose of system. applicationexception is to identify the source of the error.

When the reader processes a file derived from system. during applicationexception, you can imagine that the exception is caused by the code library of the application being executed, rather than. net base class library or.. Net runtime engine.

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.