From 91eab74af8ace4892d733372ea3710858055eaf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=95?= Date: Mon, 25 Mar 2024 16:36:03 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E6=AD=A3=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/ControllerExceptionHandler.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/cs-restful/src/main/java/com/cf/cs/restful/exception/ControllerExceptionHandler.java b/cs-restful/src/main/java/com/cf/cs/restful/exception/ControllerExceptionHandler.java index 7c93fbf..a88a93d 100644 --- a/cs-restful/src/main/java/com/cf/cs/restful/exception/ControllerExceptionHandler.java +++ b/cs-restful/src/main/java/com/cf/cs/restful/exception/ControllerExceptionHandler.java @@ -23,9 +23,20 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +/** + * The type Controller exception handler. + * + * @author xajhuang @163.com + */ @ControllerAdvice @Slf4j public class ControllerExceptionHandler { + /** + * Controller not found protocol resp. + * + * @param e the e + * @return the protocol resp + */ @ExceptionHandler(NoHandlerFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody @@ -38,6 +49,12 @@ public class ControllerExceptionHandler { errMsg.toArray(new String[0])); } + /** + * Controller global exception protocol resp. + * + * @param e the e + * @return the protocol resp + */ @ExceptionHandler({MethodArgumentNotValidException.class}) @ResponseBody public ProtocolResp controllerGlobalException(MethodArgumentNotValidException e) { @@ -52,6 +69,12 @@ public class ControllerExceptionHandler { errMsg.toArray(new String[0])); } + /** + * Common error exception protocol resp. + * + * @param ex the ex + * @return the protocol resp + */ @ExceptionHandler({CommonErrorCodeException.class}) @ResponseBody public ProtocolResp commonErrorException(Exception ex) { @@ -60,6 +83,14 @@ public class ControllerExceptionHandler { new String[] {ex.getMessage()}); } + /** + * Handle exception protocol resp. + * + * @param rsp the rsp + * @param req the req + * @param ex the ex + * @return the protocol resp + */ @ExceptionHandler(SecurityProtocolException.class) @ResponseBody public ProtocolResp handleException(HttpServletResponse rsp,