doufei9805 2013-06-20 11:12
浏览 72

通过kohana中的控制器进行异常处理

I am following the tutorial at http://kohanaframework.org/3.3/guide/kohana/tutorials/error-pages for Kohana 3.3

The following code is at classes/http/exception/404.php

 <?php
    class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
        public function get_response(){
            $view = View::factory('errors/404');
            $view->message = $this->getMessage();
     
            $response = Response::factory()
                ->status(404)
                ->body($view->render());
     
            return $response;
        }
    }

When trying to give an incorrect url like

localhost/myapp/xyz

The following error comes up

ErrorException [ Parse Error ]:
APPPATH\classes\http\exception\404.php [ 3 ]
1 <?php
2 class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
3 
4 
5 
6 
7 
8 
{PHP internal call} » Kohana_Core::shutdown_handler()

In bootstrap.php the code for init is

Kohana::init(array(
    'base_url'   => '/myapp/',
    'errors' => TRUE,
    'index_file' => FALSE,
));

How can I fix this? Thanks.

  • 写回答

2条回答 默认 最新

  • dongll0502 2013-06-20 14:53
    关注

    A couple of things to check:

    • Does the errors/404 view exist at APPPATH/views/errors/404.php?
    • Does the class filepath and name use StudlyCaps APPPATH\Classes\HTTP\Exception\404.php?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码