1
yhj
2025-05-20 7b34a626f1e0d8db378ff877429464c008b42bd3
gdbg/gdbg/Controllers/PrintController.cs
@@ -99,7 +99,7 @@
        }
        private static string ExtractErrorMessage(string oracleMessage)
       /* private static string ExtractErrorMessage(string oracleMessage)
        {
            // 匹配 "ORA-20002:" 后的具体错误信息
            string pattern = @"ORA-20002:.*?:\s(.*?)(\n|$)";
@@ -112,8 +112,26 @@
            // 如果无法匹配,则返回完整错误信息
            return oracleMessage;
        }*/
        private static string ExtractErrorMessage(string oracleMessage)
        {
            // 匹配多个 ORA-20002: 后的段落,提取最后一个
            var matches = System.Text.RegularExpressions.Regex.Matches(
                oracleMessage,
                @"ORA-20002:(.*?)(?=ORA-\d{5}:|$)"
            );
            if (matches.Count > 0)
            {
                // 提取最后一个匹配项,去除换行和多余空格
                return matches[matches.Count - 1].Groups[1].Value.Trim();
            }
            // 默认返回原始错误
            return oracleMessage;
        }
    }
}