mirror of https://gitee.com/xiaonuobase/snowy
parent
738ca7802e
commit
1477ed0ac9
|
@ -18,6 +18,7 @@ import cn.hutool.json.JSONUtil;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import vip.xiaonuo.common.exception.CommonException;
|
||||
import vip.xiaonuo.common.pojo.CommonResult;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -43,6 +44,8 @@ public class GlobalErrorViewController {
|
|||
CommonResult<String> commonResult = new CommonResult<>(404, "路径不存在", null);
|
||||
Object model = request.getAttribute("model");
|
||||
if(ObjectUtil.isNotEmpty(model)) {
|
||||
if(model instanceof Exception){
|
||||
if(model instanceof CommonException) {
|
||||
JSONObject errorObj = JSONUtil.parseObj(model);
|
||||
Integer code = errorObj.getInt("code");
|
||||
String msg = errorObj.getStr("msg");
|
||||
|
@ -53,9 +56,10 @@ public class GlobalErrorViewController {
|
|||
} else {
|
||||
commonResult = CommonResult.error();
|
||||
}
|
||||
if(model instanceof Exception){
|
||||
Exception e = (Exception) model;
|
||||
log.error(">>> 服务器未知异常,具体信息:", e);
|
||||
} else {
|
||||
commonResult = CommonResult.error();
|
||||
log.error(">>> 服务器未知异常,具体信息:", (Exception) model);
|
||||
}
|
||||
}
|
||||
}
|
||||
return commonResult;
|
||||
|
|
Loading…
Reference in New Issue