繁体   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