package com.java1234.miaosha.exception;
import com.java1234.miaosha.entity.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {
@ExceptionHandler(value = Exception.class)
public R exceptionHandler(HttpServletRequest request, Exception e){
System.out.println("全局异常捕获");
return R.error("服务端异常,请联系管理员"+"<br/>"+e.getMessage()+"<br/>"+e.getStackTrace());
}
}
全局统一异常处理
最新推荐文章于 2024-05-28 09:25:21 发布