Java exception Handling in projects

Source: Internet
Author: User

First, Java exception class introduction.

Throwable: There are two important subclasses: Exception (Exception) and error (Errors), both of which are important subclasses of Java exception handling, each of which contains a large number of subclasses.

There is a better blog,http://blog.csdn.net/hguisu/article/details/6155636 to introduce Java exceptions.

Second, the exception handling mode.

In a Java application, the exception handling mechanism is: Throw an exception, catch an exception.

Third, the use of the program.

2 Ways of Handling
1, throw new exception on the method body write throws to the upper layer, and finally to the Controller AOP processing method to log.
2. Do not use try if you know the error clearly. Catch: The way you handle processing includes logging and not throwing it to the outermost layer.  Unexpected exceptions are given to Controller AOP processing. I personally am this.

The object should be data-validated and legal when it is processed by the incoming algorithm.

Java exception Handling in projects

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.