Based on this documentation, I've implemented a catch all route which routes to an error page.
Here is the last route in my bootstrap.php
Route::set('default', '<path>', array('path' => '.+'))
->defaults(array(
'controller' => 'errors',
'action' => '404',
));
However I keep getting this exception thrown when I try and go to a non existent page
Kohana_Exception [ 0 ]: Required route
parameter not passed: path
If I make the <path> segment optional (i.e. wrap it in parenthesis) then it just seems to load the home route, which is...
Route::set('home', '')
->defaults(array(
'controller' => 'home',
'action' => 'index',
));
The home route is defined first.
I execute my main request like so
$request = Request::instance();
try {
// Attempt to execute the response
$request->execute();
} catch (Exception $e) {
if (Kohana::$environment === Kohana::DEVELOPMENT) throw $e;
// Log the error
Kohana::$log->add(Kohana::ERROR, Kohana::exception_text($e));
// Create a 404 response
$request->status = 404;
$request->response = Request::factory(Route::get('default')->uri())->execute();
}
$request->send_headers();
echo $request->response;
This means that the 404 header is sent to the browser, but I assumed by sending the request to the capture all route then it should show the 404 error set up in my errors controller.
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Errors extends Controller_Base {
public function before() {
parent::before();
}
public function action_404() {
$this->bodyClass[] = '404';
$this->internalView = View::factory('internal/not_found');
$longTitle = 'Page Not Found';
$this->titlePrefix = $longTitle;
}
}
Why won't it show my 404 error page?