Handle exception and error for web
Updated at 1691037510000Overview
Handling exceptions and discrete errors can lead to difficulties in tracking or missing errors. Therefore, EzyPlatform has provided pre-defined classes for handling exceptions and errors.
Exception Handling
Exceptions thrown during the processing of requests in controllers and interceptors will be handled if they are annotated with @TryCatch. EzyPlatform has provided the WebGlobalExceptionHandler class to handle some exceptions. You can create a subclass as follows:
@ExceptionHandler public class EzyWebGlobalExceptionHandler extends WebGlobalExceptionHandler {}
Error Handling
Exceptions that are not handled will be considered errors. EzyPlatform also provides the WebGlobalErrorHandler class to handle basic-level errors. You can create a subclass as follows:
@EzySingleton public class EzyWebGlobalErrorHandler extends WebGlobalErrorHandler {}
Note
When using these classes, try to use exceptions that are pre-defined by ezyfox, ezyhttp, or ezyplatform. If not, you will need to add handling code to the handler classes you created above.