Заменить последнюю строку bootstrap.php на:
/**
* Set the production status
*/
define('IN_PRODUCTION', FALSE);
/**
* Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
* If no source is specified, the URI will be automatically detected.
*/
$request = Request::instance();
try
{
$request->execute();
}
catch (Kohana_Exception404 $e)
{
$request = Request::factory('error/404')->execute();
}
catch (Kohana_Exception403 $e)
{
$request = Request::factory('error/403')->execute();
}
catch (ReflectionException $e)
{
$request = Request::factory('error/404')->execute();
}
catch (Kohana_Request_Exception $e)
{
$request = Request::factory('error/404')->execute();
}
catch (Exception $e)
{
if ( ! IN_PRODUCTION )
{
throw $e;
}
$request = Request::factory('error/500')->execute();
}
echo $request->send_headers()->response;
Создать новый контроллер " error.php ":
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Error extends Controller {
public function action_404()
{
$this->request->status = 404;
$this->request->headers['HTTP/1.1'] = '404';
$this->request->response = 'error 404';
}
public function action_403()
{
$this->request->status = 403;
$this->request->headers['HTTP/1.1'] = '403';
$this->request->response = 'error 403';
}
public function action_500()
{
$this->request->status = 500;
$this->request->headers['HTTP/1.1'] = '500';
$this->request->response = 'error 500';
}
} // End Error
Создание двух файлов ( исключение 404.php и исключение 403.php ) в папке " кохана ":
<?php defined('SYSPATH') or die('No direct access');
class Kohana_Exception403 extends Kohana_Exception {
public function __construct($message = 'error 403', array $variables = NULL, $code = 0)
{
parent::__construct($message, $variables, $code);
}
} // End Kohana_Exception 403
<?php defined('SYSPATH') or die('No direct access');
class Kohana_Exception404 extends Kohana_Exception {
public function __construct($message = 'error 404', array $variables = NULL, $code = 0)
{
parent::__construct($message, $variables, $code);
}
} // End Kohana_Exception 404
Теперь вы можетевыдает 404 и 403 ошибки вручную (ошибка 500 не выдается;)
throw new Kohana_Exception404;
throw new Kohana_Exception403;