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),
));

我只是想看到值'here'得到显示,我已经在Kohana_Exception的处理程序方法中给出了,但是执行从来没有到达那一行。

我还注意到,给init(errors)一个假值并不能关闭股票异常页面。

我使用了过时的异常处理例程。在Kohana 3.3中,必须使用下面链接中解释的方法http://kohanaframework.org/3.3/guide/kohana/tutorials/error-pages