麻了一一一
2018-12-10 22:22
public class ExceptionHandle {
//这里是捕获异常并处理的方法
@ExceptionHandler(value = Exception.class)
@ResponseBody
public Result handle(Exception e) {
if (e instanceof GirlException) {
//这里的强制类型转换是必须的吗?如果是,上面的条件判断在判断什么?
GirlException girlException = (GirlException) e;
return ResultUtil.failure(girlException.getCode(), girlException.getMessage());
}else {
logger.error("【系统异常】{}", e);
return ResultUtil.failure(-1, "未知错误");
}
}
}
要强转,要不然怎么获取相应的code和message
Spring Boot进阶之Web进阶
104255 学习 · 425 问题
相似问题