| | |
| | | |
| | | } |
| | | |
| | | private static string ExtractErrorMessage(string oracleMessage) |
| | | /* private static string ExtractErrorMessage(string oracleMessage) |
| | | { |
| | | // 匹配 "ORA-20002:" 后的具体错误信息 |
| | | string pattern = @"ORA-20002:.*?:\s(.*?)(\n|$)"; |
| | |
| | | |
| | | // 如果无法匹配,则返回完整错误信息 |
| | | 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; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |