|
@@ -1,10 +1,11 @@
|
|
|
package com.uas.eis.exception;
|
|
package com.uas.eis.exception;
|
|
|
|
|
|
|
|
-import com.uas.eis.entity.ErrorMsg;
|
|
|
|
|
|
|
+import com.uas.eis.entity.ErrorMessage;
|
|
|
import com.uas.eis.sdk.entity.ApiResult;
|
|
import com.uas.eis.sdk.entity.ApiResult;
|
|
|
import org.apache.log4j.Logger;
|
|
import org.apache.log4j.Logger;
|
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.ui.ModelMap;
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
@@ -31,9 +32,10 @@ public class ExceptionHandlerAdvice {
|
|
|
ModelMap map = new ModelMap();
|
|
ModelMap map = new ModelMap();
|
|
|
//logger.error(ex);
|
|
//logger.error(ex);
|
|
|
ex.printStackTrace();
|
|
ex.printStackTrace();
|
|
|
- map.put("errCode", -1);
|
|
|
|
|
- map.put("errMsg", "server error");
|
|
|
|
|
- map.put("errDesc",ex.getMessage());
|
|
|
|
|
|
|
+ map.put("code", ErrorMessage.SYS_ILLEGAL.getCode());
|
|
|
|
|
+ map.put("message", StringUtils.isEmpty(ex.getMessage())?ErrorMessage.SYS_ILLEGAL.getMessage():ex.getMessage());
|
|
|
|
|
+ map.put("requestId",request.getHeader("RequestId"));
|
|
|
|
|
+ map.put("data",null);
|
|
|
return map;
|
|
return map;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -49,10 +51,11 @@ public class ExceptionHandlerAdvice {
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
public ModelMap handleSystemError(SystemException ex, HttpServletRequest request) {
|
|
public ModelMap handleSystemError(SystemException ex, HttpServletRequest request) {
|
|
|
ModelMap map = new ModelMap();
|
|
ModelMap map = new ModelMap();
|
|
|
- ErrorMsg errorMsg = ex.getErrorMsg();
|
|
|
|
|
- map.put("errCode", errorMsg.getErrCode());
|
|
|
|
|
- map.put("errMsg", errorMsg.getErrMsg());
|
|
|
|
|
- map.put("errDesc",errorMsg.getErrDesc());
|
|
|
|
|
|
|
+ ApiResult apiResult = ex.getApiResult();
|
|
|
|
|
+ map.put("code", apiResult.getCode());
|
|
|
|
|
+ map.put("message",apiResult.getMessage());
|
|
|
|
|
+ map.put("requestId",apiResult.getRequestId());
|
|
|
|
|
+ map.put("data",apiResult.getData());
|
|
|
return map;
|
|
return map;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -75,6 +78,4 @@ public class ExceptionHandlerAdvice {
|
|
|
return map;
|
|
return map;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|