Answer the question
In order to leave comments, you need to log in
Exception handling in Kohana 3.3 (404 error)?
Hello. Has anyone experienced creating their own 404 error page on Kohana 3.3. If there are, please respond. I can't figure out how exactly to get the status of the request, and if it is != 200, then display the corresponding error page to the user (403, 404, etc.).
Answer the question
In order to leave comments, you need to log in
Isn't it? - kohanaframework.org/3.3/guide/kohana/tutorials/error-pages
In 3.3 they made it great, you don't have to check anything, just override the HTTP_Exception_404 class, in which all the logic is implemented in the get_response method
class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
/**
* Generate a Response for the 404 Exception.
*
* The user should be shown a nice 404 page.
*
* @return Response
*/
public function get_response()
{
$view = View::factory('errors/404');
// Remembering that `$this` is an instance of HTTP_Exception_404
$view->message = $this->getMessage();
$response = Response::factory()
->status(404)
->body($view->render());
return $response;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question