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

@@ -12,7 +12,8 @@ import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.restful.ServicesRequestLogBean;
import com.nis.restful.RestServiceException;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.ServiceRuntimeException;
import com.nis.util.Constants;
import com.nis.util.ExceptionUtil;
import com.nis.web.controller.BaseRestController;
@@ -40,10 +41,8 @@ public class ServicesRequestLogController extends BaseRestController {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(ExceptionUtil.getExceptionMsg(e));
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "获取系统操作日志失败");
}
throw ((RestServiceException) e);
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
"获取系统操作日志失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
}
return testServiceResponse( System.currentTimeMillis() - start, request, response, "获取系统操作日志成功",