[英]Kohana 404 custom page
I have been looking around and following each tutorials,there is one which stands out. 我一直在寻找并遵循每个教程,有一个突出。 http://blog.lysender.com/2011/02/kohana-3-1-migration-custom-error-pages/ <-- i followed this tutorial and everything went smoothly http://blog.lysender.com/2011/02/kohana-3-1-migration-custom-error-pages/ < - 我按照本教程,一切顺利
but there has been an exception that i cant seem to find. 但有一个例外,我似乎无法找到。 im currently having this exception 我目前有这个例外
Fatal error: Exception thrown without a stack frame in Unknown on line 0
all of my codes are thesame to the site-link. 我的所有代码都与网站链接相同。 please help me.. im bugging around for this since ever, i've looked through here also Kohana 3 - redirect to 404 page but since im a beginner, its really hard understanding it. 请帮助我..我一直在为此烦恼,我在这里也看了Kohana 3 - 重定向到404页面,但由于我是一个初学者,它真的很难理解它。 I've also found out that there is a major revamp from KO 3.0 to 3.1 how about KO 3.2? 我还发现从KO 3.0到3.1有一个重大的改进如何关于KO 3.2? Thank you for your help guys :) 谢谢你们的帮助:)
From the kohana source-code. 来自kohana源代码。
- > If you receive *Fatal error: Exception thrown without a stack frame in Unknown on line 0*, it means there was an error within your exception handler. If using the example above, be sure *404.php* exists under */application/views/error/*.
Maybe it helps. 也许有帮助。 This probably has been fixed, but I'm not following the kohana development that much. 这可能已经修复了,但我并没有那么多关注kohana的发展。 It's related to pull request #246: https://github.com/kohana/core/pull/246 and this is the source: https://github.com/kohana/core/pull/246/files#L208L76 这与拉请求#246有关: https : //github.com/kohana/core/pull/246这是来源: https : //github.com/kohana/core/pull/246/files#L208L76
here is how I do it with Kohana 3.2 这是我如何用Kohana 3.2做的
try { $request = $request->execute(); } catch(Kohana_HTTP_Exception_404 $e) { $request = Request::factory('errors/404')->execute(); } catch(Exception $e) { $request = Request::factory('errors/500')->execute(); } echo $request->send_headers()->body();
class Controller_Errors extends Controller { public function __construct($request, $response) { parent::__construct($request, $response); } public function action_404() { $this->response->body(View::factory('errors/404')); } public function action_500() { $this->response->body(View::factory('errors/500')); } }
Create 2 corresponding error pages (404.php and 500.php in views/errors) 创建2个相应的错误页面(404.php和500.php的视图/错误)
Add new route to your bootstrap.php or use default one (depends on you project's structure), just make sure Controller_Errors can be reached when exception is thrown 将新路由添加到bootstrap.php或使用默认路由(取决于项目的结构),只需确保在抛出异常时可以访问Controller_Errors
throw new HTTP_Exception_404;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.