May I ask you what aspects should be considered for unified exception handling in a multi-tier JAVA enterprise application? Such as how to design custom exceptions, how to catch them, whether to define error codes, which are checked Exception, which are unchecked Exception, etc. Hope there is a master not stint:)
I am dealing with it this way for the time being, and it is very basic. I think answering my own questions is to throw a brick to attract jade.
1. Inheriting the RuntimeException's BusinessException and unifying it as a thrown exception; 2. Define the enumeration of ErrCode and the types of exceptions thrown by BusinessException; 3. Except logging and other processing for exceptions thrown by each layer, the business layer is unified catch and processed by the Action layer (i.e. the top layer in the background); (including returning to a unified error page) 4. The business exception returned by the ordinary method (the program is normal, but the business branch is wrong) is returned by the error code in the return value; 5. Define a CommonResult for the above return value, including the error code and HashMap； of the returned parameter;