Commit 7aaf2ac4 by zhufx

错误类封装

parent 19e34a9c
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/20
* Time: 11:13
*/
namespace Hdll\Services\Order\Enum;
class OrderError
{
//common
const PARAMETER_ERR = ["msg" => "参数错误", "code" => 400, "errorCode" => 22001];
const PERMISSION_DENIED = ["msg" => "没有权限,%s", "code" => 401, "errorCode" => 22104];
//validator
const UNDEFINED_VALIDATOR = ["msg" => "未定义验证其验证器%s","code" => 500, "errorCode" => 22100];
const EMPTY_COMPARE_VALUE = ["msg" => "对比数值不能为空", "code" => 500, "errorCode" => 22101];
const UNKONW_OPERATION = ["msg" => "未知操作符%s", "code" => 500, "errorCode" => 22102];
//联系人
const NO_FOUND_CONSIGNEE = ["msg" => "未找到联系人信息", "code" => 404, "errorCode" => 22103];
//预约
const RESERVATION_OVERRUN = ["msg" => "预约时间不能早于当前时间", "code" => 400, "errorCode" => 22105];
const RES_IS_REST = ["msg" => "休息日不能添加预约", "code" => 400, "errorCode" => 22106];
//买家
const FREEZE = ["msg" => "休息日不能添加预约", "code" => 400, "errorCode" => 22107];
//order
const O_PRICE_ABNORMAL = ["msg" => "价格异常,请重新购买", "code" => 400, "errorCode" => 22108];
const O_TYPE_ERR = ["msg" => "订单类型不正确", "code" => 400, "errorCode" => 22109];
public static function atranslate($message,$param)
{
if ( empty($param) ) {
return $message;
}
array_unshift($param,$message);
return sprintf(...$param);
}
public function getError($code) {
$reflect = new \ReflectionClass(self::class);
return $reflect->getConstant($code);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment