Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, you need to make sure you are loading your module by including it in the modules section of your application/bootstrap.php file like so</p> <pre><code>Kohana::modules(array( 'my'=&gt;MODPATH.'my' ) ); </code></pre> <p>The fact that you mentioned going directly to the url for your error handler controller triggers a 404 error makes me think your module has not been loaded.</p> <p>I would also suggest a few more changes.</p> <p>http_response_exception.php does not need to extend Kohana_Exception, since this class is not an exception, but an exception handler. Along those same lines, a more appropriate class name might be Exception_Handler, since the class is not representing an exception, but handling them. Secondly, because of how you've named this file, it should be located in modules/my/classes/http/response/exception.php. Other than that, the code for this class looks ok.</p> <p>Similarly, because of how you've named your controller, it should be located and named a bit differently. Move it to modules/my/classes/controller/error/handler.php</p> <p>Remember that underscores in a class name means a new directory, as per <a href="http://kohanaframework.org/3.2/guide/kohana/conventions" rel="nofollow">http://kohanaframework.org/3.2/guide/kohana/conventions</a></p> <p>Finally, I don't think you really need to extend the Kohana_Core class here, but instead just register your own custom exception handler. You can register your custom exception handler in either your application's bootstrap file, or in your module's init file with the following generic code:</p> <pre><code>set_exception_handler(array('Exception_Handler_Class', 'handle_method')); </code></pre> <p>Here's a customer exception handler I use, which is pretty similar to yours:</p> <pre><code>&lt;?php defined('SYSPATH') or die('No direct script access.'); class Exception_Handler { public static function handle(Exception $e) { $exception_type = strtolower(get_class($e)); switch ($exception_type) { case 'http_exception_404': $response = new Response; $response-&gt;status(404); $body = Request::factory('site/404')-&gt;execute()-&gt;body(); echo $response-&gt;body($body)-&gt;send_headers()-&gt;body(); return TRUE; break; default: if (Kohana::$environment == Kohana::DEVELOPMENT) { return Kohana_Exception::handler($e); } else { Kohana::$log-&gt;add(Log::ERROR, Kohana_Exception::text($e)); $response = new Response; $response-&gt;status(500); $body = Request::factory('site/500')-&gt;execute()-&gt;body(); echo $response-&gt;body($body)-&gt;send_headers()-&gt;body(); return TRUE; } break; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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