|
@@ -2,7 +2,7 @@ package cn.com.qmth.examcloud.web.support;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.util.JsonMapper;
|
|
|
-import cn.com.qmth.examcloud.web.cloud.AppSelfHolder;
|
|
|
+import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
|
import cn.com.qmth.examcloud.web.enums.HttpServletRequestAttribute;
|
|
|
import cn.com.qmth.examcloud.web.exception.ApiFlowLimitedException;
|
|
|
import cn.com.qmth.examcloud.web.exception.SequenceLockException;
|
|
@@ -58,22 +58,22 @@ public class CustomExceptionHandler {
|
|
|
StatusResponse body = null;
|
|
|
|
|
|
if (null == cause) {
|
|
|
- body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", "系统异常");
|
|
|
+ body = new StatusResponse(SystemProperties.APP_CODE + "-500", "系统异常");
|
|
|
cause = e;
|
|
|
} else if (cause instanceof ApiFlowLimitedException) {
|
|
|
body = new StatusResponse("503", "limited. RPC");
|
|
|
} else if (cause instanceof StatusException) {
|
|
|
StatusException se = (StatusException) cause;
|
|
|
- body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-" + se.getCode(), se.getDesc());
|
|
|
+ body = new StatusResponse(SystemProperties.APP_CODE + "-" + se.getCode(), se.getDesc());
|
|
|
} else if (cause instanceof DataIntegrityViolationException) {
|
|
|
try {
|
|
|
DataIntegrityViolationTransverter.throwIfDuplicateEntry((DataIntegrityViolationException) cause);
|
|
|
- body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", "数据完整性错误");
|
|
|
+ body = new StatusResponse(SystemProperties.APP_CODE + "-500", "数据完整性错误");
|
|
|
} catch (StatusException se) {
|
|
|
body = new StatusResponse(se.getCode(), se.getDesc());
|
|
|
}
|
|
|
} else if (cause instanceof IllegalStateException) {
|
|
|
- body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", cause.getMessage());
|
|
|
+ body = new StatusResponse(SystemProperties.APP_CODE + "-500", cause.getMessage());
|
|
|
} else if (cause instanceof javax.validation.ConstraintViolationException) {
|
|
|
javax.validation.ConstraintViolationException cvExcp = (ConstraintViolationException) cause;
|
|
|
Set<ConstraintViolation<?>> constraintViolations = cvExcp.getConstraintViolations();
|
|
@@ -88,15 +88,15 @@ public class CustomExceptionHandler {
|
|
|
errorMsg.append("; ").append(cv.getMessage());
|
|
|
}
|
|
|
}
|
|
|
- body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", errorMsg.toString());
|
|
|
+ body = new StatusResponse(SystemProperties.APP_CODE + "-500", errorMsg.toString());
|
|
|
} else if (cause instanceof SequenceLockException) {
|
|
|
- body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", cause.getMessage());
|
|
|
+ body = new StatusResponse(SystemProperties.APP_CODE + "-500", cause.getMessage());
|
|
|
} else if (cause instanceof org.springframework.jdbc.CannotGetJdbcConnectionException
|
|
|
|| cause instanceof org.springframework.orm.jpa.JpaSystemException
|
|
|
|| cause instanceof org.springframework.transaction.CannotCreateTransactionException) {
|
|
|
body = new StatusResponse("503", "limited. JDBC");
|
|
|
} else {
|
|
|
- body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", "系统异常");
|
|
|
+ body = new StatusResponse(SystemProperties.APP_CODE + "-500", "系统异常");
|
|
|
cause = e;
|
|
|
}
|
|
|
|
|
@@ -127,7 +127,7 @@ public class CustomExceptionHandler {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- StatusResponse body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", errorMsg.toString());
|
|
|
+ StatusResponse body = new StatusResponse(SystemProperties.APP_CODE + "-500", errorMsg.toString());
|
|
|
return asResult(e, body, request);
|
|
|
}
|
|
|
|
|
@@ -141,7 +141,7 @@ public class CustomExceptionHandler {
|
|
|
*/
|
|
|
@ExceptionHandler(MissingServletRequestParameterException.class)
|
|
|
public ResponseEntity<StatusResponse> handleException(MissingServletRequestParameterException e, HttpServletRequest request) {
|
|
|
- StatusResponse body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", e.getMessage());
|
|
|
+ StatusResponse body = new StatusResponse(SystemProperties.APP_CODE + "-500", e.getMessage());
|
|
|
return asResult(e, body, request);
|
|
|
}
|
|
|
|
|
@@ -155,7 +155,7 @@ public class CustomExceptionHandler {
|
|
|
*/
|
|
|
@ExceptionHandler(MissingServletRequestPartException.class)
|
|
|
public ResponseEntity<StatusResponse> handleException(MissingServletRequestPartException e, HttpServletRequest request) {
|
|
|
- StatusResponse body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", e.getMessage());
|
|
|
+ StatusResponse body = new StatusResponse(SystemProperties.APP_CODE + "-500", e.getMessage());
|
|
|
return asResult(e, body, request);
|
|
|
}
|
|
|
|
|
@@ -169,7 +169,7 @@ public class CustomExceptionHandler {
|
|
|
*/
|
|
|
@ExceptionHandler(HttpMessageNotReadableException.class)
|
|
|
public ResponseEntity<StatusResponse> handleException(HttpMessageNotReadableException e, HttpServletRequest request) {
|
|
|
- StatusResponse body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500",
|
|
|
+ StatusResponse body = new StatusResponse(SystemProperties.APP_CODE + "-500",
|
|
|
"Required request body is missing");
|
|
|
return asResult(e, body, request);
|
|
|
}
|
|
@@ -184,7 +184,7 @@ public class CustomExceptionHandler {
|
|
|
*/
|
|
|
@ExceptionHandler(Exception.class)
|
|
|
public ResponseEntity<StatusResponse> handleException(Exception e, HttpServletRequest request) {
|
|
|
- StatusResponse body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", "系统错误");
|
|
|
+ StatusResponse body = new StatusResponse(SystemProperties.APP_CODE + "-500", "系统错误");
|
|
|
return asResult(e, body, request);
|
|
|
}
|
|
|
|