<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # onExceptionHandle 異常的回調 如果在控制器方法執行過程中拋出了異常,那么會直接跳轉到onExceptionHandle方法。 默認我們提供了一個異常處理。 ```php /** * 異常的回調 * @param \Exception $e */ public function onExceptionHandle(\Exception $e) { switch ($this->request_type) { case SwooleMarco::HTTP_REQUEST: $this->http_output->end($e->getMessage()); break; case SwooleMarco::TCP_REQUEST: $this->send($e->getMessage()); break; } } ``` 如果需要修改請繼承Controller。 實際上我們建議在你開始編寫代碼之前將Controller,Model, 等常用的類都繼承一遍,變成自己業務的基類。這樣才能保證框架更新的時候不會出現代碼沖突問題。 由于協程的存在,異常嵌套處理比較麻煩,下面將其情況一一說明。 1.普通的controller異常測試,onExceptionHandle將接收到回調 ```php /** * 普通的controller異常測試 * @throws \Exception */ public function http_testExceptionHandleII() { throw new \Exception('ExceptionHandle'); } ``` 2.普通model內的異常測試,onExceptionHandle將接收到回調 ```php /** * 普通model的異常測試 * @throws \Exception */ public function http_testExceptionHandleIII() { $this->testModel = $this->loader->model('TestModel', $this); $result = $this->testModel->test_exception(); } ``` 3.協程的model內的異常測試,onExceptionHandle將接收到回調 ```php /** * 協程的model報錯需要增加try catch捕獲,否則無法拋出 */ public function http_testExceptionHandleIV() { $this->testModel = $this->loader->model('TestModel', $this); $result = yield $this->testModel->test_exceptionII(); } ``` 4.總結:無論協程或者是多層協程嵌套,還是普通的代碼,或者普通代碼混合協程,都可以一路向上throw。并且可以通過try catch捕獲。和正常代碼沒有任何區別。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看