You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace LaneWeChat\Core;
// 错误提示类
// 该类用于处理和返回错误信息,方便在程序中统一管理和显示错误。
class Msg {
/**
* 返回错误信息
* 根据提供的错误码和错误信息,构造一个错误消息数组,并退出程序。
*
* @param int $code 错误码,用于标识具体的错误类型。
* @param string $errorMsg 自定义错误信息,如果为空,则使用默认错误信息。
* @return Ambigous <multitype:unknown , multitype:, boolean> 返回类型可能不明确因为exit函数会导致脚本终止。
*/
public static function returnErrMsg($code, $errorMsg = null) {
// 初始化错误消息数组,包含错误码
$returnMsg = array('error_code' => $code);
// 如果提供了自定义错误信息,则添加到错误消息数组中
if (!empty($errorMsg)) {
$returnMsg['custom_msg'] = $errorMsg;
}
// 如果没有提供自定义错误信息,则使用默认错误信息
// 这里可以根据错误码从错误码常量类中获取对应的错误信息
// $returnMsg['custom_msg'] = MsgConstant::ERROR_NO_BINDING_TEXT;
$returnMsg['custom_msg'] = '出错啦!'.$returnMsg['custom_msg'];// 添加默认错误前缀信息
exit($returnMsg['custom_msg']);// 退出程序并输出错误信息
}
}
?>