WANG il y a 5 ans
Parent
commit
dbe8d3a1e2

+ 6 - 3
src/main/java/cn/com/qmth/examcloud/web/support/CustomExceptionHandler.java

@@ -101,7 +101,8 @@ public class CustomExceptionHandler {
 			body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500",
 					cause.getMessage());
 		} else if (cause instanceof org.springframework.jdbc.CannotGetJdbcConnectionException
-				|| cause instanceof org.springframework.orm.jpa.JpaSystemException) {
+				|| cause instanceof org.springframework.orm.jpa.JpaSystemException
+				|| cause instanceof org.springframework.transaction.CannotCreateTransactionException) {
 			body = new StatusResponse("503", "limited");
 		} else {
 			body = new StatusResponse(AppSelfHolder.get().getAppCode() + "-500", "系统异常");
@@ -220,7 +221,8 @@ public class CustomExceptionHandler {
 		if (alwaysOK) {
 			if (t instanceof ApiFlowLimitedException
 					|| t instanceof org.springframework.jdbc.CannotGetJdbcConnectionException
-					|| t instanceof org.springframework.orm.jpa.JpaSystemException) {
+					|| t instanceof org.springframework.orm.jpa.JpaSystemException
+					|| t instanceof org.springframework.transaction.CannotCreateTransactionException) {
 				httpStatus = HttpStatus.SERVICE_UNAVAILABLE;
 				printStackTrace = false;
 			} else {
@@ -229,7 +231,8 @@ public class CustomExceptionHandler {
 		} else {
 			if (t instanceof ApiFlowLimitedException
 					|| t instanceof org.springframework.jdbc.CannotGetJdbcConnectionException
-					|| t instanceof org.springframework.orm.jpa.JpaSystemException) {
+					|| t instanceof org.springframework.orm.jpa.JpaSystemException
+					|| t instanceof org.springframework.transaction.CannotCreateTransactionException) {
 				httpStatus = HttpStatus.SERVICE_UNAVAILABLE;
 				printStackTrace = false;
 			} else {