From 711fd971275401adc48b6a25865ea4594bc7fb75 Mon Sep 17 00:00:00 2001 From: hao <1836460075@qq.com> Date: 星期三, 21 五月 2025 16:31:36 +0800 Subject: [PATCH] Merge branch 'master' of http://43.142.96.171:8080/r/~yhj/XM_GK_HD --- gdbg/gdbg/Controllers/PrintController.cs | 35 +++++++++++++++++++++++++++++------ 1 files changed, 29 insertions(+), 6 deletions(-) diff --git a/gdbg/gdbg/Controllers/PrintController.cs b/gdbg/gdbg/Controllers/PrintController.cs index a694643..6115c16 100644 --- a/gdbg/gdbg/Controllers/PrintController.cs +++ b/gdbg/gdbg/Controllers/PrintController.cs @@ -1,9 +1,10 @@ -锘縰sing Microsoft.AspNetCore.Mvc; -using System.Threading.Tasks; +锘縰sing gdbg.Models; using gdbg.Services; -using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; using Oracle.ManagedDataAccess.Client; -using gdbg.Models; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Threading.Tasks; namespace gdbg.Controllers { @@ -93,7 +94,8 @@ // 鍏朵粬 Oracle 閿欒 return StatusCode(500, new { - message = "鏁版嵁搴撻敊璇細" + ex.Message + // message = "鏁版嵁搴撻敊璇細" + ex.Message + message = ExtractErrorMessage(ex.Message) }); } catch (Exception ex) @@ -117,7 +119,7 @@ // 濡傛灉鏃犳硶鍖归厤锛屽垯杩斿洖瀹屾暣閿欒淇℃伅 return oracleMessage; }*/ - private static string ExtractErrorMessage(string oracleMessage) + /* private static string ExtractErrorMessage(string oracleMessage) { // 鍖归厤澶氫釜 ORA-20002: 鍚庣殑娈佃惤锛屾彁鍙栨渶鍚庝竴涓� var matches = System.Text.RegularExpressions.Regex.Matches( @@ -133,9 +135,30 @@ // 榛樿杩斿洖鍘熷閿欒 return oracleMessage; + }*/ + + + private static string ExtractErrorMessage(string oracleMessage) + { + // 鍖归厤鎵�鏈� ORA-20002: 閿欒娈� + var matches = Regex.Matches(oracleMessage, @"ORA-20002:\s*(.*?)(?=(ORA-\d{5}:|$))", RegexOptions.Singleline); + + if (matches.Count > 0) + { + // 杩斿洖鏈�閲岄潰涓�鏉★紙鏈�鍚庝竴涓級 + string raw = matches[matches.Count - 1].Groups[1].Value; + + // 鍘绘帀绫讳技 "Error in PrintAndUpdate procedure:" 寮�澶� + string cleaned = Regex.Replace(raw, @"^Error.*?:", "", RegexOptions.IgnoreCase).Trim(); + + return string.IsNullOrWhiteSpace(cleaned) ? raw.Trim() : cleaned; + } + + return oracleMessage; // fallback } + } } -- Gitblit v1.9.3