From be5b58387c821526bfa1f0eb4b9dada86a6c1958 Mon Sep 17 00:00:00 2001 From: fanbo <3412853751@qq.com> Date: Wed, 25 Dec 2024 08:26:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9core=E6=96=87=E4=BB=B6=E5=A4=B9?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E4=BB=A3=E7=A0=81=E6=96=87=E4=BB=B6msg.lib.p?= =?UTF-8?q?hp=E5=92=8Cmsgconstant.lib.php=E5=81=9A=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/msg.lib.php | 25 ++++++++----- core/msgconstant.lib.php | 76 ++++++++++++++++++++++++++++++++++------ 2 files changed, 83 insertions(+), 18 deletions(-) diff --git a/core/msg.lib.php b/core/msg.lib.php index 8fdf508..359f963 100644 --- a/core/msg.lib.php +++ b/core/msg.lib.php @@ -1,19 +1,28 @@ 返回类型可能不明确,因为exit函数会导致脚本终止。 + */ public static function returnErrMsg($code, $errorMsg = null) { + // 初始化错误消息数组,包含错误码 $returnMsg = array('error_code' => $code); + // 如果提供了自定义错误信息,则添加到错误消息数组中 if (!empty($errorMsg)) { $returnMsg['custom_msg'] = $errorMsg; } - $returnMsg['custom_msg'] = '出错啦!'.$returnMsg['custom_msg']; - exit($returnMsg['custom_msg']); + // 如果没有提供自定义错误信息,则使用默认错误信息 + // 这里可以根据错误码从错误码常量类中获取对应的错误信息 + // $returnMsg['custom_msg'] = MsgConstant::ERROR_NO_BINDING_TEXT; + $returnMsg['custom_msg'] = '出错啦!'.$returnMsg['custom_msg'];// 添加默认错误前缀信息 + exit($returnMsg['custom_msg']);// 退出程序并输出错误信息 } } ?> diff --git a/core/msgconstant.lib.php b/core/msgconstant.lib.php index 0025dc5..4248500 100644 --- a/core/msgconstant.lib.php +++ b/core/msgconstant.lib.php @@ -1,20 +1,76 @@