Commit a595dfee by guojx

Merge branch 'feature-2023-01-目标配置' into 'developer'

目标跟进接口报错处理

See merge request !879
parents 2c49c07b 27a17ce9
......@@ -53,25 +53,6 @@ public class GlobalExceptionHandler extends WebBaseController {
return res;
}
@ResponseBody
@ExceptionHandler(RuntimeException.class)
public RestResponse controllerRunExceptionForRest(HttpServletResponse response, RuntimeException ex) {
logger.error("controllerRunException:{}", ex.getMessage(), ex);
RestResponse res = new RestResponse();
res.setCode(String.valueOf(HaoBanErrCode.ERR_3.getCode()));
String message = ex.getMessage();
if (message != null && message.indexOf(ShowFrontMessageException.class.getName()) > -1) {
Matcher matcher = pattern.matcher(message);
while (matcher.find()) {
message = (matcher.group(2));
}
} else {
message = HaoBanErrCode.ERR_3.getMsg();
}
res.setMessage(message);
return res;
}
/**
* 全局异常
*/
......@@ -113,6 +94,12 @@ public class GlobalExceptionHandler extends WebBaseController {
return resultResponse(errCode, null, fieldError.getField() + fieldError.getDefaultMessage());
}
@ResponseBody
@ExceptionHandler(TargetException.class)
public RestResponse bindException(HttpServletResponse response, TargetException ex) {
return RestResponse.failure(String.valueOf(HaoBanErrCode.ERR_3.getCode()), ex.getMessage());
}
/**
* valid 异常告警 @ReuqestBody
*
......
package com.gic.haoban.manage.web.exception;
/**
* @Author guojx
* @Date 2023/1/17 14:32
*/
public class TargetException extends RuntimeException{
public TargetException() {
}
public TargetException(String message) {
super(message);
}
public TargetException(String message, Throwable cause) {
super(message, cause);
}
}
......@@ -7,6 +7,7 @@ import com.gic.api.base.commons.Page;
import com.gic.commons.util.HttpClient;
import com.gic.commons.web.qo.PageQo;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.manage.web.exception.TargetException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
......@@ -119,7 +120,7 @@ public class DataTargetHttpUtils {
Config config = ConfigService.getConfig("COMMON.data-api-config");
String value = config.getProperty(apolloKey, "");
if (StringUtils.isBlank(value)) {
throw new RuntimeException("数据接口配置有误!");
throw new TargetException("数据接口配置有误!");
}
LOGGER.info("{}:Apollo查询的配置信息:{}", apolloKey, value);
String[] split = value.split("\\+\\+\\+\\+");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment