开发者

What sort of exceptions should I be throwing from inside Kohana 3?

I've seen the code examples on this article, but t开发者_JS百科hrowing 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜