细化日志查询接口的异常处理:数据验证未通过等客户端原因引起的异常归为RestServiceException(status=400);在服务程序运行过程中发生的内容异常归为ServiceRuntimeException(status=500)

This commit is contained in:
zhangdongxu
2018-11-29 11:48:32 +08:00
parent 50aca2d2df
commit fcea7ed13e
8 changed files with 280 additions and 192 deletions

View File

@@ -16,7 +16,9 @@ import com.nis.domain.restful.TrafficNetflowPortInfoList;
import com.nis.domain.restful.TrafficNmsServerStatisticList;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.restful.ServiceRuntimeException;
import com.nis.util.Constants;
import com.nis.util.ExceptionUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
import com.nis.web.service.ServicesRequestLogService;
@@ -60,8 +62,14 @@ public class NmsInfoController extends BaseRestController {
}
} catch (Exception e) {
throw new RestServiceException(thread, System.currentTimeMillis() - start, "上报服务器状态信息异常:" + e.getMessage(),
RestBusinessCode.unknow_error.getValue());
logger.error("上报服务器状态信息异常:" + ExceptionUtil.getExceptionMsg(e));
if (e instanceof RestServiceException) {
throw (RestServiceException) e;
} else {
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start, "上报服务器状态信息异常:" + e.getMessage(),
RestBusinessCode.unknow_error.getValue());
}
}
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "上报服务器状态信息成功",
Constants.IS_DEBUG ? trafficNmsServerStatisticList : null);
@@ -84,8 +92,13 @@ public class NmsInfoController extends BaseRestController {
RestBusinessCode.missing_args.getValue());
}
} catch (Exception e) {
throw new RestServiceException(thread, System.currentTimeMillis() - start,
logger.error("上报NmsDiRule信息异常:" + ExceptionUtil.getExceptionMsg(e));
if (e instanceof RestServiceException) {
throw (RestServiceException) e;
} else {
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
"上报NmsDiRule信息异常:" + e.getMessage(), RestBusinessCode.unknow_error.getValue());
}
}
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "上报NmsDiRule信息成功",
Constants.IS_DEBUG ? nmsDiRuleList : null);
@@ -111,8 +124,12 @@ public class NmsInfoController extends BaseRestController {
}
} catch (Exception e) {
throw new RestServiceException(thread, System.currentTimeMillis() - start,
if (e instanceof RestServiceException) {
throw (RestServiceException) e;
} else {
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
"上报trafficNetflowPort信息异常:" + e.getMessage(), RestBusinessCode.unknow_error.getValue());
}
}
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
"上报trafficNetflowPort信息成功", Constants.IS_DEBUG ? trafficNetflowPortInfoList : null);