如何用我设计的页面替换库存异常页面(红色和灰色页面)。
我按照以下步骤
步骤 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 的处理程序方法中给出的值“here”得到显示,但执行从未触及那条线。
我还注意到,为 init(errors) 提供错误值并没有关闭库存异常页面。