Question

I've looked at how shadowhand (the main guy behind Kohana currently) set up his bootstrap.php file to handle exceptions on GitHub.

I thought, "that's cool", so I incorporated something similar.

However, instead of serving up a view, I'd like to send the request to a different route (or at least point it to a controller/action pair).

So this part on GitHub

 // Create a 404 response
$request->status = 404;
$request->response = View::factory('template')
->set('title', '404')
->set('content', View::factory('errors/404'));

Would be something like (pseudo code of course)

 // Create a 404 response
$request->status = 404;
$request->response = Route::get('404_error'); // which will map to a route outlined above in bootstrap.php

How can I do this? Thanks

Was it helpful?

Solution

Using Request::factory with the uri:

$request->response = Request::factory('error/404')->execute();

Or with the route:

$request->response = Request::factory(Route::get('error_404')->uri())->execute();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top