P61集中处理所有异常,老师这里直接把异常抛出去了,把Throwable改成Exception
然后打印异常信息即可
@ExceptionHandler(value = Throwable.class)
public R handleException(Throwable throwable){
return R.error(BizCodeEnume.UNKNOW_EXCEPTION.getCode (),BizCodeEnume.UNKNOW_EXCEPTION.getMsg());
}
@ExceptionHandler(value = Exception.class)
public R handleException(Exception e){
log.error(e.getMessage(),e);
return R.error(BizCodeEnume.UNKNOW_EXCEPTION.getCode (),BizCodeEnume.UNKNOW_EXCEPTION.getMsg());
}