From 2038901e2d34885dce30a1679cc5b802526469f0 Mon Sep 17 00:00:00 2001 From: TinyAnts Date: Fri, 12 Aug 2022 12:13:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=A8=E5=B1=80=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=B1=BBbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hxkj/common/exception/GlobalException.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/like-common/src/main/java/com/hxkj/common/exception/GlobalException.java b/server/like-common/src/main/java/com/hxkj/common/exception/GlobalException.java index 0c331f29..2a0b1b8e 100644 --- a/server/like-common/src/main/java/com/hxkj/common/exception/GlobalException.java +++ b/server/like-common/src/main/java/com/hxkj/common/exception/GlobalException.java @@ -38,6 +38,18 @@ public class GlobalException { return AjaxResult.failed(HttpEnum.SYSTEM_ERROR.getCode(), HttpEnum.SYSTEM_ERROR.getMsg()); } + /** + * 拦截自定义抛出异常 + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(BaseException.class) + @ResponseBody + public AjaxResult handleException(BaseException e) { + int code = e.getCode(); + String msg = e.getMsg(); + return AjaxResult.failed(code, msg); + } + /** * 拦截表单参数校验FROM */