|
@@ -8,7 +8,7 @@ package com.platform.exception;
|
|
|
|
|
|
|
|
|
import com.platform.entity.Result;
|
|
|
-import lombok.extern.log4j.Log4j2;
|
|
|
+import com.platform.utils.R;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.util.StringUtils;
|
|
@@ -30,9 +30,17 @@ public class GlobalExceptionHandler {
|
|
|
@ResponseBody
|
|
|
@ExceptionHandler(CommonBaseException.class)
|
|
|
@ResponseStatus(HttpStatus.OK)
|
|
|
- public Result runtimeExceptionHandler(HttpServletRequest request, CommonBaseException e) {
|
|
|
+ public Result CommonBaseExceptionHandler(HttpServletRequest request, CommonBaseException e) {
|
|
|
log.error(request.getRequestURI() + ":" + e.getMsg());
|
|
|
return Result.failure(StringUtils.isEmpty(e.getCode()) ? Result.CODE_FAILURE : e.getCode(), e.getMsg());
|
|
|
}
|
|
|
|
|
|
+ @ResponseBody
|
|
|
+ @ExceptionHandler(RuntimeException.class)
|
|
|
+ @ResponseStatus(HttpStatus.OK)
|
|
|
+ public R runtimeExceptionHandler(HttpServletRequest request, RuntimeException e) {
|
|
|
+ log.error(request.getRequestURI() + ":" + e.getMessage());
|
|
|
+ return R.error(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
}
|