簡體   English   中英

Kohana / PHP自定義異常處理在Kohana 3.3中不起作用

[英]Kohana/PHP Custom exception handling not working in Kohana 3.3

如何用我設計的頁面替換庫存例外頁面(紅色和灰色的頁面)。

我按照以下步驟

步驟1)將System / classes / Kohana / Exception.php復制到Application / classes / Kohana / Exception.php並添加以下代碼段

class Kohana_Exception extends Kohana_Kohana_Exception { 


    public static function handler(Exception $e) {

       echo 'here'; die;

        switch (get_class($e)) {
            case 'HTTP_Exception_404':
                echo 'here';
                $this->HandleException(404, 'errors/404');
                return TRUE;
                break;

            default:
                return Kohana_Kohana_Exception::handler($e);
                break;
        }
    }

我檢查了Application / bootstrap.php並確保存在以下代碼

Kohana::init(array(
    'base_url'   => '/web/',
        'index_file' => '',
        'errors' => true,
        'profile'       => (Kohana::$environment == Kohana::DEVELOPMENT),

));

我只是想看到顯示在Kohana_Exception的處理程序方法中的值“這里”得到顯示,但是執行從未達到該值。

我還注意到,給init(errors)賦一個假值並不能關閉股票例外頁面。

我正在使用過時的異常處理例程。 在Kohana 3.3中,必須使用以下鏈接中介紹的方法http://kohanaframework.org/3.3/guide/kohana/tutorials/error-pages

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM