分布式事务异常判断
This commit is contained in:
parent
e65a801a62
commit
8b16ce48de
@ -1,28 +1,28 @@
|
||||
package net.jieyuu.exception;
|
||||
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import net.jieyuu.utils.JsonData;
|
||||
//import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
//import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
//import org.springframework.web.bind.annotation.ResponseBody;
|
||||
//
|
||||
//@ControllerAdvice
|
||||
//@Slf4j
|
||||
//public class CustomExceptionHandle {
|
||||
//
|
||||
// @ExceptionHandler(value = Exception.class)
|
||||
// @ResponseBody
|
||||
// public JsonData Handle(Exception e) {
|
||||
//
|
||||
// if (e instanceof BizException) {
|
||||
// BizException bizException = (BizException) e;
|
||||
// log.info("[业务异常]{}", e);
|
||||
// return JsonData.buildCodeAndMsg(bizException.getCode(), bizException.getMsg());
|
||||
//
|
||||
// } else {
|
||||
// log.info("[系统异常]{}", e);
|
||||
// return JsonData.buildError("全局异常,未知错误");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.jieyuu.utils.JsonData;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@ControllerAdvice
|
||||
@Slf4j
|
||||
public class CustomExceptionHandle {
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseBody
|
||||
public JsonData Handle(Exception e) {
|
||||
|
||||
if (e instanceof BizException) {
|
||||
BizException bizException = (BizException) e;
|
||||
log.info("[业务异常]{}", e);
|
||||
return JsonData.buildCodeAndMsg(bizException.getCode(), bizException.getMsg());
|
||||
|
||||
} else {
|
||||
log.info("[系统异常]{}", e);
|
||||
return JsonData.buildError("全局异常,未知错误");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -140,6 +140,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
request.setName(userDO.getName());
|
||||
request.setUserId(userDO.getId());
|
||||
JsonData jsonData = couponFeignService.addNewUserCoupon(request);
|
||||
if (jsonData.getCode() != 0) {
|
||||
throw new RuntimeException("发放优惠券异常");
|
||||
}
|
||||
log.info("发放新用户注册优惠券: {},结果:{}", request.toString(), jsonData.toString());
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user