package cn.exrick.xboot.core.common.exception;
|
|
import cn.exrick.xboot.core.common.utils.ResultUtil;
|
import cn.exrick.xboot.core.common.vo.Result;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
/**
|
* @author xfei
|
* @date 2023/4/26 15:32
|
*/
|
@ControllerAdvice
|
public class GlobalExceptionHandler {
|
//指定出现什么异常执行这个方法
|
@ExceptionHandler(Exception.class)
|
@ResponseBody //为了返回数据
|
public Result error(Exception e) {
|
e.printStackTrace();
|
return ResultUtil.error(500,"系统异常请联系管理员!");
|
}
|
}
|