我应该从 Kohana 3 内部抛出什么样的异常?
我已经在这篇文章中看到了代码示例< /a>,但抛出 Controller_Exception_404
会产生错误。
我刚刚抛出了简单的异常。我记得在 Kohana 2.3 中你可以根据情况抛出不同的东西。
有谁有什么时候应该抛出什么异常的列表?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您想要的异常是
Kohana_Request_Exception
。以下是 Kohana 定义的所有异常的列表(使用grep -iR "class .*Exception" .
生成):如果您想要 404 响应代码,我认为您还必须在你的控制器
我不知道“官方”最佳实践是什么,但这是我通过尝试发现的。
I think the exception you want is
Kohana_Request_Exception
. Here's a list of all the exceptions Kohana defines (generated usinggrep -iR "class .*Exception" .
):If you want a 404 response code, I think you'll also have to do this in your controller
I don't know what the "official" best practice is, but this is what I've found by playing around.