A few days ago, and a colleague was responsible for reorganizing the abnormal processing of the company's online banking products. The original abnormal treatment uses an exception to store the error message, the location and error code in the session, so that the program process will not be The appearance of abnormality is completely interrupted, the idea of this is very good, but in many places in the specific implementation, there is no abnormality in accordance with normal procedures, but directly on the call, Once the call class is also the same throw without capturing records, the error after the exception is captured after the outer layer is captured, and it can only be found through the STACK, and sometimes because the system is under a base engine. The secondary development is completed, the secondary development code and the engine have a difference. If the exception in the secondary development code is not captured in this section, it will be lost, although this is the engine design. Question, but because the base engine cannot be modified casually, we need to enter the engine process in the secondary development.
The process of solving this problem is as follows: First, the exception is classified, an exception is divided into procedures and exceptions. The program is abnormal is an uncertain abnormality that appears in the program. This exception is programmer, if there is a need to appear in the production environment The way to mask the user, and this abnormality must display detailed error message, location and stack so that the programmer can quickly find problems; and the function exception is user-oriented, and the user is operating due to various reasons. Failure, if the user is transferred, the amount submitted exceeds the balance of the specified transfer account. At this time, you need to actively generate an exception and save it in the session, and the program process continues to go down, and can guide the error page. The exception information is taken from the session during the page processing. These information do not need to be complex, just tell the user's operation failure, in our system, only the error code is recorded when the function is exception, and there is a specialized File storage error code and error message;
Secondly at the boundary of the secondary development code and engine code, all exceptions that may occur in the secondary code are intercepts all the exceptions in the second code.
From the IBM website, find a good article on exception handling, reference here: http://www-900.ibm.com/developerworks/cn/java/j-merlin/index8.shtml