Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>All links to Kohana's documentation in this post are for version 3.3</h2> <p>You won't get what you want by overwriting just one method. Below I explain the methods that you can overwrite in order to achieve what you want. Just make just sure you put the right code in the right method.</p> <p>Don't try to do everything in one place. While it will be all in one place is will most likely become a mess.</p> <hr> <h2>Kohana_Exception::handler()</h2> <p><a href="http://kohanaframework.org/3.3/guide-api/Kohana_Exception#handler" rel="nofollow">Kohana_Exception::handler()</a> is for when exceptions reach the exception handler or like you showed, in the shutdown handler. The last chance you have to display a nice error page in production environments. It outputs the result of <a href="http://kohanaframework.org/3.3/guide-api/Kohana_Exception#_handler" rel="nofollow">Kohana_exception::_handler()</a>, which is a Response object, and is therefor not suited to be called inside <a href="http://kohanaframework.org/3.3/guide-api/Request_Client_Internal#execute_request" rel="nofollow">Request_Client_Internal::execute_response()</a>.</p> <p>For production: Log the original exception. Since this scenario matches the description of <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1" rel="nofollow">HTTP Status Code 500 (Internal Server Error)</a> Kohana_Exception::handler() should display a 500 error page.</p> <p>During development you probably want to call <code>parent::handler()</code>.</p> <h2>Kohana_Exception::_handler()</h2> <p><a href="http://kohanaframework.org/3.3/guide-api/Kohana_Exception#_handler" rel="nofollow">Kohana_Exception::_handler()</a> return a Response object, so it is suited to be called in <a href="http://kohanaframework.org/3.3/guide-api/Request_Client_Internal#execute_request" rel="nofollow">Request_Client_External::execute_response()</a>, <a href="http://kohanaframework.org/3.3/guide-api/Kohana_Exception#handler" rel="nofollow">Kohana_Exception::handler()</a> and <a href="http://kohanaframework.org/3.3/guide-api/View#__toString" rel="nofollow">View::__toString()</a>.</p> <h2>HTTP_Exception::get_response()</h2> <p><a href="http://kohanaframework.org/3.3/guide-api/HTTP_Exception#get_response" rel="nofollow">HTTP_Exception::get_response()</a> will get called for exceptions extending HTTP_Exception, with the exception of exceptions extending HTTP_Exception_Expected. A few examples of exceptions extending HTTP_Expected_Exception are the 3xx and 401 HTTP_Exceptions.</p> <p>By default it returns <a href="http://kohanaframework.org/3.3/guide-api/Kohana_Exception#response" rel="nofollow">Kohana_Exception::response()</a>. Overwrite it in specific exceptions to return specific responses for said exception. Overwrite it in HTTP_Exception when you want the replace the default response.</p> <h2>Kohana_Exception::response()</h2> <p><a href="http://kohanaframework.org/3.3/guide-api/Kohana_Exception#response" rel="nofollow">Kohana_Exception::response()</a> is responsible for collecting the data needed to render the Kohana_Exception::$error_view template. An example of output can be seen on the <a href="http://kohanaframework.org/3.3/guide/kohana/errors#example" rel="nofollow">kohana/errors page of the userguide</a>.</p> <p>Change Kohana_Exception::$error_view when you want a different layout for the same data. Overwrite Kohana_Exception::response() to replace the entire thing.</p> <p>PS. Kevin pointed you to the 3.2 documentation. How to do this is very different for 3.2 and 3.3.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload