先检查一下运行用户配置情况

@throws Exception 如果检查失败，则抛出异常
@return array 成功的情况下会返回用户及用户组信息，格式：[用户信息, 用户组信息]
424178
private function checkUser() {
        //事件监听守护进程的配置(跟事件及其监听器的配置是两码事)
        $config = $this->appContext->getConfig('eventListend') ?: [];
        $username = isset($config['user']) ? $config['user'] : 'nobody';
        $groupName = isset($config['group']) ? $config['group'] : 'nobody';

        $userInfo = posix_getpwnam($username);
        if (!$userInfo) {
            _throw("用户“{$username}”不存在，启动失败");
        }

        $groupInfo = posix_getgrnam($groupName);
        if (!$groupInfo) {
            _throw("用户组“{$groupName}”不存在，启动失败");
        }

        return [$userInfo, $groupInfo];
    }
755139
public function connect()
    {
        $options = & $this->options;
        
        if (!$this->connection && !@$this->connection->sqlstate) {
            $this->connection = @ new \mysqli($options['host'], $options['username'], $options['password'], $options['database'], $options['port']);
            // error
            if (mysqli_connect_errno()) {
                $msg = mysqli_connect_error();  // 这是中文编码？
                throw new Exception('Db connect error.');
            }
            
            if ($this->connection->connect_error != '') {
                $msg = 'Db Error: Could not connect to database. Connection Error #' . $this->connection->connect_errno . ': ' . $this->connection->connect_error;
                throw new Exception('Db connect error.');
            }
            
            //set charset
            $options['charset'] = isset($options['charset']) ? trim($options['charset']) : 'utf8';
            if ($this->getCharset() != $options['charset']) {
                $this->setCharset($options['charset']);
            }
        }
    }
949671
public function actionGetSavedRoutes()
    {
        $request = \Yii::$app->request;
        if ($request->getIsOptions()) {
            return $this->ResponseOptions($this->verbs()['index']);
        }
        try{
            return Menu::getSavedRoutes();
        }catch(Exception $e){
            throw new Exception($e);
        }
    }
1091254
public function delete()
    {
        if (!$this->queueName) {
            throw new \Exception('QueueName 队列名称不存在');
        }

        if (!$this->message) {
            throw new \Exception('Message 消息不存在');
        }

        $params = [
            'queueName'     => $this->queueName,
            'receiptHandle' => $this->message->get('receiptHandle'),
        ];

        $request = new DeleteMessageRequest($params);

        try {
            $this->client->send($request);
        } catch (RequestException $e) {
            throw $e;
        } catch (ResponseException $e) {
            $message = $e->getBody();

            if (!$message->has('code')) {
                throw $e;
            } else if (!in_array($message->get('code'), ['4430', '4440'])) {    // 4430：句柄无效，4440：队列不存在
                throw $e;
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }
312245
protected function buildSql()
    {
        $query = $this->getQuery();
        if (
            !isset($query['table']) || empty($query['table'])
            || !isset($query['where']) || empty($query['where'])
        ) {
            throw new Exception(str_cover('"{type}"查询参数不完整', [
                '{type}' => 'delete'
            ]), 101300401);
        }
        return 'DELETE FROM ' . $this->quoteTableName($query['table']) . ' WHERE ' . $query['where'];
    }
246567
public function getSuccessful()
    {
        $results = [];
        foreach ($this->hash as $key) {
            if (!($this->hash[$key] instanceof \Exception)) {
                $results[] = $this->hash[$key];
            }
        }

        return $results;
    }
442232
public function getMessage(): array
    {
        if (!empty($this->message)) {
            return $this->message;
        }

        try {
            $message = XML::parse(strval($this->app['request']->getContent()));
        } catch (\Throwable $e) {
            throw new Exception('Invalid request XML: '.$e->getMessage(), 400);
        }

        if (!is_array($message) || empty($message)) {
            throw new Exception('Invalid request XML.', 400);
        }

        if ($this->check) {
            $this->validate($message);
        }

        return $this->message = $message;
    }
784371
public function actionIndex()
    {
        $request = \Yii::$app->request;
        if ($request->getIsOptions()) {
            return $this->ResponseOptions($this->verbs()['index']);
        }
        try{
            return Menu::getPageMenus(Yii::$app->request->queryParams);

        }catch(Exception $e)
        {
            throw new Exception($e);
        }



    }
1200815
final public function truncate()
    {
        if (!$this->DB) {
            throw  new Exception('您还没有连接数据库', Exception::CODE_DATABASE_ERROR);
        }
        $table = $this->getTable();
        $sql = "truncate table " . $table;
        $this->sql = $sql;
        /**
         * 只获取sql
         */
        if ($this->justSql) {
            return true;
        }
        return $this->DB->execute($sql);
    }
1311668
public function execute()
    {
        $this->_setOptions();

        $sResponse = $this->_execute();
        $this->_saveStatusCode();

        $iCurlErrorNumber = $this->_getErrorNumber();

        $this->_close();

        if ($iCurlErrorNumber) {
            $host = $this->getUrl();
            $parameters = http_build_query($this->getParameters(), "", "&");
            $message = $this->_getErrorMessage($iCurlErrorNumber);
            throw new Exception("cURL failed with message '$message' when calling '$host?$parameters'");
        }

        return $sResponse;
    }
1264150
public function run()
    {
        if (($exception = Yii::$app->getErrorHandler()->exception) === null) {
            return '';
        }

        if ($exception instanceof \HttpException) {
            $code = $exception->statusCode;
        } else {
            $code = $exception->getCode();
        }

        if ($exception instanceof Exception) {
            $name = $exception->getName();
        } else {
            $name = $this->defaultName ?: Yii::t('yii', 'Error');
        }

        if ($code) {
            $name .= " (#$code)";
        }

        if ($exception instanceof UserException) {
            $message = $exception->getMessage();
        } else {
            $message = $this->defaultMessage ?: Yii::t('yii', 'An internal server error occurred.');
        }


        if (Yii::$app->getRequest()->getIsAjax()) {
            $rr = new RequestResponse();

            $rr->success = false;
            $rr->message = "$name: $message";

            return (array)$rr;
        } else {
            //All requests are to our backend
            //TODO::Add image processing
            $info = pathinfo(\Yii::$app->request->pathInfo);
            if ($extension = ArrayHelper::getValue($info, 'extension')) {
                $extension = \skeeks\cms\helpers\StringHelper::strtolower($extension);
                if (in_array($extension, ['js', 'css'])) {
                    \Yii::$app->response->format = Response::FORMAT_RAW;
                    if ($extension == 'js') {
                        \Yii::$app->response->headers->set('Content-Type', 'application/javascript');
                    }
                    if ($extension == 'css') {
                        \Yii::$app->response->headers->set('Content-Type', 'text/css');
                    }

                    $url = \Yii::$app->request->absoluteUrl;
                    return "/* File: '{$url}' not found */";
                }
            }

            return $this->controller->render($this->view ?: $this->id, [
                'name' => $name,
                'message' => $message,
                'exception' => $exception,
            ]);
        }
    }
1054965
public function actionRun()
    {
        $crontab = Task::findAll(['switch' => Task::SWITCH_ACTIVE]);
        $tasks = [];

        foreach ($crontab as $task) {
            // 第一次运行,先计算下次运行时间
            if (!$task->next_rundate) {
                $task->next_rundate = $task->getNextRunDate();
                $task->save(false);
                continue;
            }
            // 判断运行时间到了没
            if ($task->next_rundate <= date('Y-m-d H:i:s')) {
                $tasks[] = $task;
            }
        }

        $this->executeTask($tasks);
        return ExitCode::OK;
    }
117309
public function verify()
    {
        $data = $_GET;
        $sign = $data['md5'];

        if (Helper::verify($data, $sign) === false) {
            throw new \Exception('盈华讯方异步通知验签失败');
        }
        return $data;
    }
810330
public function read(): string
	{
		if ($this->connected() === false)
		{
			throw new \Exception('Not connected');
		}

		$response = '';
		$continue = true;

		while ($continue == true)
		{
			$data = null;

			try
			{
				$data = $this->readLine();
			}
			catch (\Exception $e)
			{
				$continue = false;
			}

			if (!is_null($data))
			{
				$response .= $data;
			}
		}

		return $response;
	}
76524
public function getURL() {

        if ($this->_generatedURL != "")
            return $this->_generatedURL;

        if (!isset($this->_merchantID))
            throw new Exception('Merchant ID not set, use the setMerchantID() method');
        if (!isset($this->_secretCode))
            throw new Exception('Secretcode ID not set, use the setSecretCode() method');

        if (!isset($this->data->ic_country)) {
            if (count($this->_country) == 1) {
                $this->data->ic_country = current($this->_country);
            } else
                $this->data->ic_country = $this->_defaultCountryCode;
        }

        if (!isset($this->data->ic_issuer) && isset($this->data->ic_paymentmethod)) {
            if (count($this->_issuer) == 1) {
                $this->data->ic_issuer = current($this->_issuer);
            } else
                throw new Exception('Issuer not set, use the setIssuer() method');
        }

        if (!isset($this->data->ic_language)) {
            if (count($this->_language) == 1) {
                $this->data->ic_language = current($this->_language);
            } else
                throw new Exception('Language not set, use the setLanguage() method');
        }

        if (!isset($this->data->ic_currency)) {
            if (count($this->_currency) == 1) {
                $this->data->ic_currency = current($this->_currency);
            } else
                throw new Exception('Currency not set, use the setCurrency() method');
        }

        if (!isset($this->data->ic_amount))
            throw new Exception('Amount not set, use the setAmount() method');

        if (!isset($this->data->ic_orderid))
            throw new Exception('OrderID not set, use the setOrderID() method');

        if (!isset($this->data->ic_reference))
            $this->data->ic_reference = "";
        if (!isset($this->data->ic_description))
            $this->data->ic_description = "";

        /*
         * Dynamic URLs
         * @since 1.0.1
         */
        if (!isset($this->data->ic_urlcompleted))
            $this->data->ic_urlcompleted = "";
        if (!isset($this->data->ic_urlerror))
            $this->data->ic_urlerror = "";

        $this->data->ic_version = $this->_checkout_version;
        $this->data->ic_merchantid = $this->_merchantID;
        $this->data->chk = $this->generateCheckSumDynamic();

        /* @since version 1.0.2 */
        if ($this->_webservice) {
            require_once(DIR . DS . "icepay_api_webservice.php");

            if (!isset($this->data->ic_issuer) || $this->data->ic_issuer == "")
                throw new Exception("Issuer not set");

            //$ws = Icepay_Api_Webservice::getInstance()->paymentService();
            $ws = Icepay_Api_Webservice::getInstance()->paymentService();
            $ws->setMerchantID($this->_merchantID)
                    ->setSecretCode($this->_secretCode)
                    ->setSuccessURL($this->data->ic_urlcompleted)
                    ->setErrorURL($this->data->ic_urlerror);
            try {
                $this->_generatedURL = $ws->checkOut($this->paymentObj, true);
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            return $this->_generatedURL;
        }

        if (isset($this->data->ic_paymentmethod)) {
            $this->_generatedURL = $this->postRequest($this->basicMode(), $this->prepareParameters());
        } else {
            $this->_generatedURL = sprintf("%s&%s", $this->basicMode(), $this->prepareParameters());
        }

        return $this->_generatedURL;
    }
249287
public function parseUrl()
    {
        if (self::PATH_FORMAT === $this->urlFormat) {
            $pathInfo = $this->removeUrlSuffix(Request::httpRequest()->getPathInfo(), $this->urlSuffix);
        } elseif (isset($_GET[$this->routeVar])) {
            $pathInfo = $this->removeUrlSuffix($_GET[$this->routeVar], $this->urlSuffix);
        } elseif (isset($_POST[$this->routeVar])) {
            $pathInfo = $_POST[$this->routeVar];
        } else {
            $pathInfo = '';
        }
        foreach ($this->_rules as $i => $rule) {
            $_pathinfo = $rule->parsePathInfo($this, $pathInfo);
            if (false !== $_pathinfo) {
                return $_pathinfo;
            }
        }
        if ($this->throwNotMatchRule) {
            // 不匹配规则时抛出异常
            throw new Exception(str_cover('"{pathInfo}"找不到对应的URL解析规则，不能确定路由', [
                '{pathInfo}' => $pathInfo,
            ]), 100900101);
        } else {
            // 没有匹配的规则，直接返回pathinfo本身
            return $pathInfo;
        }
    }
297565
public function getResult()
    {
        $result = parent::getResult();
        if (is_array($result) && isset($result['error'])) {
            throw new Exception($result['error']);
        }
        return $result;
    }