这个是放在系统内部的 全局异常处理类:
package com.hg.service.bussiness.system.execption;
import com.hg.core.code.BaseCode;
import com.hg.core.exception.BaseException;
import com.hg.core.exception.ErrorInfo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(value = BaseException.class)
@ResponseBody
public ErrorInfo<Object> baseErrorHandler(BaseException e) throws Exception {
ErrorInfo<Object> r = new ErrorInfo<>();
r.setMessage(e.getMessage());
r.setCode(e.getCode());
return r;
}
@ExceptionHandler(value = Exception.class)
@ResponseBody
public ErrorInfo<Object> excepti