熔断返回信息封装

yun-zuoyi
alwaysfrin 6 years ago
parent 87aa6644fd
commit 1371f94838

@ -18,22 +18,44 @@ public class BaseFallBackBean {
// LOGGER.error("【微服出错,熔断】{}",cause.getCause()); // LOGGER.error("【微服出错,熔断】{}",cause.getCause());
// cause.printStackTrace(); // cause.printStackTrace();
/**
*
* @param cause
* @return
*/
public BaseResultBean makeBaseFallBack(Throwable cause){ public BaseResultBean makeBaseFallBack(Throwable cause){
LOGGER.error("【熔断信息】{}", cause.getMessage()); LOGGER.error("【熔断信息】{}", cause.getMessage());
LOGGER.error("【熔断原因】{}", cause.getCause()); LOGGER.error("【熔断原因】{}", cause.getCause());
cause.printStackTrace();
return makeBaseFallBack("【微服熔断】服务暂停,请稍后再试。", cause); return makeBaseFallBack("【微服熔断】服务暂停,请稍后再试。", cause);
} }
/**
*
* @param msg
* @param cause
* @return
*/
public BaseResultBean makeBaseFallBack(String msg, Throwable cause){ public BaseResultBean makeBaseFallBack(String msg, Throwable cause){
LOGGER.error("【熔断信息】{}", cause.getMessage()); LOGGER.error("【熔断信息】{}", cause.getMessage());
LOGGER.error("【熔断原因】{}", cause.getCause()); LOGGER.error("【熔断原因】{}", cause.getCause());
cause.printStackTrace();
return BaseResultBean.buildBaseResultBean(false, cause.getMessage() + ",信息:" + msg); return BaseResultBean.buildBaseResultBean(false, cause.getMessage() + ",信息:" + msg);
} }
/**
*
* @return
*/
public BaseResultBean makeBaseFallBack(){ public BaseResultBean makeBaseFallBack(){
return makeBaseFallBack("【微服熔断】服务暂停,请稍后再试。"); return makeBaseFallBack("【微服熔断】服务暂停,请稍后再试。");
} }
/**
*
* @param msg
* @return
*/
public BaseResultBean makeBaseFallBack(String msg){ public BaseResultBean makeBaseFallBack(String msg){
return BaseResultBean.buildBaseResultBean(false, msg); return BaseResultBean.buildBaseResultBean(false, msg);
} }

Loading…
Cancel
Save