Commit dd5650d0 authored by duanruiming's avatar duanruiming

[update] 优化异常处理

parent 0290f42c
......@@ -5,7 +5,7 @@ package net.wanji.utc.hisense.controller;
* @date 2022/12/1 15:07
*/
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
......@@ -73,7 +73,7 @@ public class SignalStatusController {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
signalStatusService.receiveLightStatus(hisenseLightStatusPojos);
} catch (JsonParseException e) {
} catch (JsonMappingException e) {
}
return jsonViewObject.success("海信灯态接收成功");
}
......
......@@ -176,7 +176,10 @@ public class SignalStatusServiceImpl implements SignalStatusService {
lightsStatusVO.setPhasePlanId(String.valueOf(planId));
List<CrossSchemePhaseCountDownDTO> crossSchemePhaseCountDownList = CrossSchemePhaseTimeCountCache.crossSchemePhaseCountDownList;
LightsStatusVO lightsStatusVOCurrent = setLightsStatusVOPhaseNoAndCountDown(lightsStatusVO, crossId, runTime, planId, crossSchemePhaseCountDownList);
log.error("周期倒计时值:{}", crossId + lightsStatusVOCurrent.getCyclePhaseCountDown());
if (Objects.isNull(lightsStatusVOCurrent)) {
log.error("当前海信路口灯态信息异常:{}", lightsStatusVO);
continue;
}
SignalDataCache.runningStateInfoCacheNoLamp.put(crossId, lightsStatusVOCurrent);
}
}
......@@ -186,6 +189,7 @@ public class SignalStatusServiceImpl implements SignalStatusService {
/**
* 通过周期倒计时判断当前相位号,相位倒计时时间
*
* @param lightsStatusVO
* @param crossId
* @param runTime
......
......@@ -141,8 +141,16 @@ public class GlobalExceptionHandler {
* 输入值与数据类型不匹配
*/
@ExceptionHandler(value = HttpMessageNotReadableException.class)
public JsonViewObject httpMessageNotReadableExceptionHandler() {
return JsonViewObject.newInstance().fail("输入值与数据类型不匹配");
public JsonViewObject httpMessageNotReadableExceptionHandler(HttpServletRequest req, Exception e) {
Throwable cause = e.getCause();
String errorMessage;
if (cause != null) {
errorMessage = cause.getMessage();
} else {
errorMessage = e.getMessage();
}
log.error("输入值与数据类型不匹配:", e);
return JsonViewObject.newInstance().fail("输入值与数据类型不匹配:" + errorMessage);
}
/**
......
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