diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/exception/impl/ExceptionExecutorImpl.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/exception/impl/ExceptionExecutorImpl.java
index 59032803..758e28df 100644
--- a/sop-gateway/src/main/java/com/gitee/sop/gateway/exception/impl/ExceptionExecutorImpl.java
+++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/exception/impl/ExceptionExecutorImpl.java
@@ -22,6 +22,8 @@ public class ExceptionExecutorImpl implements ExceptionExecutor {
private static final String CONSTRAINT_VIOLATION_EXCEPTION = "ConstraintViolationException";
private static final String OPEN_EXCEPTION = "OpenException";
+ private static final String BIZ_ERROR_REGEX = "(.*?)";
+ static Pattern PATTERN = Pattern.compile(BIZ_ERROR_REGEX, Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
@Override
public ApiResponse executeException(ApiRequestContext apiRequestContext, Exception e) {
@@ -36,7 +38,14 @@ public class ExceptionExecutorImpl implements ExceptionExecutor {
}
if (exceptionClass.contains(OPEN_EXCEPTION)) {
String exceptionMessage = genericException.getExceptionMessage();
- String errorMsg = exceptionMessage.split("\n")[1];
+
+ Matcher matcher = PATTERN.matcher(exceptionMessage);
+ String errorMsg;
+ if (matcher.find()) {
+ errorMsg = matcher.group(1);
+ } else {
+ errorMsg = "biz-error@@系统错误";
+ }
// isv.common-error@@系统错误@@
String[] msgAr = errorMsg.split("@@");
return ApiResponse.error(
@@ -53,7 +62,7 @@ public class ExceptionExecutorImpl implements ExceptionExecutor {
}
private static Set findErrorMsg(String text) {
- Pattern pattern = Pattern.compile("'([^']*)'");
+ Pattern pattern = java.util.regex.Pattern.compile("'([^']*)'");
Matcher matcher = pattern.matcher(text);
Set msgList = new LinkedHashSet<>();
while (matcher.find()) {
diff --git a/sop-support/sop-service-support/src/main/java/com/gitee/sop/support/exception/OpenException.java b/sop-support/sop-service-support/src/main/java/com/gitee/sop/support/exception/OpenException.java
index bd0394ca..72f48272 100644
--- a/sop-support/sop-service-support/src/main/java/com/gitee/sop/support/exception/OpenException.java
+++ b/sop-support/sop-service-support/src/main/java/com/gitee/sop/support/exception/OpenException.java
@@ -35,6 +35,6 @@ public class OpenException extends RuntimeException {
@Override
public String toString() {
- return String.join("@@", subCode, subMsg, solution);
+ return "" + String.join("@@", subCode, subMsg, solution) + "";
}
}