Analysis of exception and exception handling framework

Source: Internet
Author: User
Tags exception handling readable

Overview

Under normal circumstances, enterprise-level applications correspond to complex business logic, in order to ensure the robustness of the system, it is necessary to face a variety of system business anomalies and run-time anomalies.

Bad exception handling can easily cause application logic to be confusing, fragile and difficult to manage. The application is flooded with fragmented exception handling code that makes the program code obscure, poorly readable, and hard to maintain.

A good exception handling framework provides a unified view of processing for exception handling for applications, separating exception handling from the normal operation logic of the program to provide a more structured and readable program architecture. In addition, a good exception handling framework is extensible, and it is easy to extend the specific exception handling logic according to the specific exception handling requirements.

In addition, the exception handling framework relies on and embodies the system architecture level to some extent. The system architecture determines the subsystems of the system, the interaction between the layers, and the exception handling framework embodies the errors and anomalies of the various interactions in this architecture. Therefore, the exception handling framework is an issue that should be considered in the context of the system architecture.

In this article, we will discuss some aspects of exception-related, and then explore some perspective or design principles for building a robust and extensible exception-handling framework. Since this article introduces some of the concepts of exception-related in the Java language, this article assumes that you are familiar with Java-related basics and understand Java EE and EJB related technologies.

Java Exception Basic Concepts

In the Java programming language, an error-trapping mechanism for exception handling is used. When a program is running, something unusual happens, the program may be interrupted, or the result of the error will occur. In this case, the program does not return any values, but instead throws an object that encapsulates the error message. The Java language provides a special exception handling mechanism to handle these exceptions. As shown in Figure 1, the Java exception architecture:

Figure 1. Java Exception Architecture

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.