views:

187

answers:

1

I've seen the code examples on this article, but throwing Controller_Exception_404 produces an error.

I've just been throwing plain exceptions. I remember in Kohana 2.3 there were different ones you could throw, depending on the situation.

Does anyone have a list of what exceptions should be thrown when?

+1  A: 

I think the exception you want is Kohana_Request_Exception. Here's a list of all the exceptions Kohana defines (generated using grep -iR "class .*Exception" .):

class Validate_Exception extends Kohana_Validate_Exception {}
class Kohana_Validate_Exception extends Kohana_Exception {
class Kohana_Request_Exception extends Kohana_Exception {  }
class Kohana_Exception extends Exception {
class Kohana_View_Exception extends Kohana_Exception {  }

If you want a 404 response code, I think you'll also have to do this in your controller

$this->request->status = 404;

I don't know what the "official" best practice is, but this is what I've found by playing around.

D. Evans