BaseException.php 672 字节
<?php

namespace app\api\library\Exception;

use think\Exception;

class BaseException extends  Exception{
    public $code = -1;
    public $msg ='参数错误';
    public $errCode = 200;

    public function __construct($params=[]) {
        if(!is_array($params)){
            return ;
//            throw  new Exception('参数必须是数组');
        }
        if(array_key_exists('code',$params)){
            $this->code = $params['code'];
        }
        if(array_key_exists('msg',$params)){
            $this->msg = $params['msg'];
        }
        if(array_key_exists('errCode',$params)){
            $this->errCode = $params['errCode'];
        }
    }
}