|
@@ -64,6 +64,8 @@ public class CustomExceptionHandler {
|
|
if (null == cause) {
|
|
if (null == cause) {
|
|
body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", "系统异常");
|
|
body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", "系统异常");
|
|
cause = e;
|
|
cause = e;
|
|
|
|
+ } else if (cause instanceof ApiFlowLimitedException) {
|
|
|
|
+ body = new StatusResponse("503", "limited");
|
|
} else if (cause instanceof StatusException) {
|
|
} else if (cause instanceof StatusException) {
|
|
StatusException se = (StatusException) cause;
|
|
StatusException se = (StatusException) cause;
|
|
body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-" + se.getCode(),
|
|
body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-" + se.getCode(),
|
|
@@ -98,8 +100,9 @@ public class CustomExceptionHandler {
|
|
} else if (cause instanceof SequenceLockException) {
|
|
} else if (cause instanceof SequenceLockException) {
|
|
body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500",
|
|
body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500",
|
|
cause.getMessage());
|
|
cause.getMessage());
|
|
- } else if (cause instanceof org.springframework.jdbc.CannotGetJdbcConnectionException) {
|
|
|
|
- body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", "网络拥堵,请稍后重试");
|
|
|
|
|
|
+ } else if (cause instanceof org.springframework.jdbc.CannotGetJdbcConnectionException
|
|
|
|
+ || cause instanceof org.springframework.orm.jpa.JpaSystemException) {
|
|
|
|
+ body = new StatusResponse("503", "limited");
|
|
} else {
|
|
} else {
|
|
body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", "系统异常");
|
|
body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", "系统异常");
|
|
cause = e;
|
|
cause = e;
|
|
@@ -215,14 +218,18 @@ public class CustomExceptionHandler {
|
|
|
|
|
|
HttpStatus httpStatus = null;
|
|
HttpStatus httpStatus = null;
|
|
if (alwaysOK) {
|
|
if (alwaysOK) {
|
|
- if (t instanceof ApiFlowLimitedException) {
|
|
|
|
|
|
+ if (t instanceof ApiFlowLimitedException
|
|
|
|
+ || t instanceof org.springframework.jdbc.CannotGetJdbcConnectionException
|
|
|
|
+ || t instanceof org.springframework.orm.jpa.JpaSystemException) {
|
|
httpStatus = HttpStatus.SERVICE_UNAVAILABLE;
|
|
httpStatus = HttpStatus.SERVICE_UNAVAILABLE;
|
|
printStackTrace = false;
|
|
printStackTrace = false;
|
|
} else {
|
|
} else {
|
|
httpStatus = HttpStatus.OK;
|
|
httpStatus = HttpStatus.OK;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if (t instanceof ApiFlowLimitedException) {
|
|
|
|
|
|
+ if (t instanceof ApiFlowLimitedException
|
|
|
|
+ || t instanceof org.springframework.jdbc.CannotGetJdbcConnectionException
|
|
|
|
+ || t instanceof org.springframework.orm.jpa.JpaSystemException) {
|
|
httpStatus = HttpStatus.SERVICE_UNAVAILABLE;
|
|
httpStatus = HttpStatus.SERVICE_UNAVAILABLE;
|
|
printStackTrace = false;
|
|
printStackTrace = false;
|
|
} else {
|
|
} else {
|