GlobalExceptionHandler.java 454 B

12345678910111213141516
  1. package com.ctsi.handler;
  2. import com.ctsi.utils.ApiResult;
  3. import org.springframework.web.bind.annotation.ExceptionHandler;
  4. import org.springframework.web.bind.annotation.RestControllerAdvice;
  5. @RestControllerAdvice
  6. public class GlobalExceptionHandler {
  7. // 全局异常拦截
  8. @ExceptionHandler
  9. public ApiResult handlerException(Exception e) {
  10. e.printStackTrace();
  11. return ApiResult.result(401, e.getMessage(), null);
  12. }
  13. }