Note that there are some explanatory texts on larger screens.

plurals
  1. POcustom error page - can't get into handler
    primarykey
    data
    text
    <p>I'm trying to add my custom pages. I'm using Kohana 3.3. The official documentation states that I should ovveride the method <code>hander</code> of native <code>Kohana_Exception</code> class. This is pretty easy to do so I've done that. Now I'm expecting that Kohana would call that method every time an exception or an error occurs. But this is not the case. I've found 2 catch blocks where an exception is caught inside <code>execute_request</code> method of <code>Kohana_Request_Client_Internal</code> class.</p> <p><strong>First catch</strong></p> <pre><code>catch (HTTP_Exception $e) { // Get the response via the Exception $response = $e-&gt;get_response(); } </code></pre> <p><strong>Second catch</strong></p> <pre><code>catch (Exception $e) { // Generate an appropriate Response object $response = Kohana_Exception::_handler($e); } </code></pre> <p>As you can see, none of the catch blocks calls <code>handler</code> method overriden by me.</p> <p>Setting your own exception handler <code>set_exception_handler</code> has no effect since it is applied only to uncaught exceptions and the exceptions like <code>404</code> are thrown and caught.</p> <p>No problems with run-time errors though. This block catches them and explicitly calls overriden <code>handler</code> method.</p> <pre><code>if (Kohana::$errors AND $error = error_get_last() AND in_array($error['type'], Kohana::$shutdown_errors)) { // Clean the output buffer ob_get_level() AND ob_clean(); // Fake an exception for nice debugging Kohana_Exception::handler(new ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line'])); // Shutdown now to avoid a "death loop" exit(1); } </code></pre> <p>So my question how do I set up everything to have custom error page for Exception and HTTP_Exception?</p> <p>PS. I can ovveride HTTP_Exception_404 and HTTP_Exception_500 to have my custom error page displayed, but I don't think that's the best option since it could work for these two, but overriding all possible HTTP_Exceptions is not a good way to go.</p> <p>PS2. Or I can set my custom view in <code>bootstrap.php</code>:</p> <pre><code>Kohana_Exception::$error_view = 'custom_error.tpl'; </code></pre> <p>Also don't like that solution.</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.
 

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