yii2 try cactch does not catch the exception, why, thank you

WBOY
Release: 2016-09-03 00:14:10
Original
1546 people have browsed it

<code>/**
* 获得银行卡
* @param array $data
* @return string
*/
public function getBank($data) {
    try {
        $client = $this->getClient();
        $params = $this->getConnectParams(array('username' => $data['username']));
        $response = $client->GetBank($params);
        $return_json = $response->GetBankResult;
        $return_arr = json_decode($return_json) ;
        $status = $return_arr->result ;
    } catch (\Exception $e) {
        self::addLog($e);
        $status = 'error';
    }
}



</code>
Copy after login
Copy after login

Why is the exception thrown by Yii yiibaseErrorException? My Exception system exception cannot catch the exception thrown by Yii? How to solve the problem of catching both system exceptions and Yii's yiibaseErrorException exception?

Reply content:

<code>/**
* 获得银行卡
* @param array $data
* @return string
*/
public function getBank($data) {
    try {
        $client = $this->getClient();
        $params = $this->getConnectParams(array('username' => $data['username']));
        $response = $client->GetBank($params);
        $return_json = $response->GetBankResult;
        $return_arr = json_decode($return_json) ;
        $status = $return_arr->result ;
    } catch (\Exception $e) {
        self::addLog($e);
        $status = 'error';
    }
}



</code>
Copy after login
Copy after login

Why is the exception thrown by Yii yiibaseErrorException? My Exception system exception cannot catch the exception thrown by Yii? How to solve the problem of catching both system exceptions and Yii's yiibaseErrorException exception?

It may be that your PHP version is too low. I remember that the PHP version upgrade note mentioned fixing abnormal problems;
I tried it with PHP5.5, and the problem you mentioned did not occur.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template