细化日志查询接口的异常处理:数据验证未通过等客户端原因引起的异常归为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

@@ -14,7 +14,9 @@ import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.restful.DkBehaviorLog;
import com.nis.domain.restful.PxyHttpLog;
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;
@@ -69,9 +71,11 @@ public class LogController extends BaseRestController {
auditLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger.error(ExceptionUtil.getExceptionMsg(e));
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(auditLogThread, System.currentTimeMillis() - start, "行为识别日志检索失败");
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
"行为识别日志检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
}else{
throw ((RestServiceException) e);
}
throw ((RestServiceException) e);
}
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "行为识别日志检索成功", page, 0);
}
@@ -93,9 +97,11 @@ public class LogController extends BaseRestController {
auditLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger.error(ExceptionUtil.getExceptionMsg(e));
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(auditLogThread, System.currentTimeMillis() - start, "PXY HTTP日志检索失败");
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
"PXY HTTP日志检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
}else{
throw ((RestServiceException) e);
}
throw ((RestServiceException) e);
}
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "PXY HTTP日志检索成功", page,
0);