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?
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法