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 @@