我一直在寻找并遵循每个教程,有一个突出。 http://blog.lysender.com/2011/02/kohana-3-1-migration-custom-error-pages/< - 我按照本教程,一切顺利
但有一个例外,我似乎无法找到。我目前有这个例外
Fatal error: Exception thrown without a stack frame in Unknown on line 0
我的所有代码都与网站链接相同。请帮助我..我一直在为此烦恼,我也在这里看了Kohana 3 - redirect to 404 page但是因为我是初学者,所以很难理解它。我还发现从KO 3.0到3.1有一个重大的改进如何关于KO 3.2?谢谢你们的帮助:)
答案 0 :(得分:1)
来自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/*.
也许有帮助。这可能已经修复了,但我并没有那么多关注kohana的发展。这与拉取请求#246相关:https://github.com/kohana/core/pull/246这是来源:https://github.com/kohana/core/pull/246/files#L208L76
答案 1 :(得分:1)
这是我如何使用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')); } }
创建2个相应的错误页面(404.php和500.php的视图/错误)
向bootstrap.php添加新路由或使用默认路由(取决于项目的结构),只需确保在抛出异常时可以访问Controller_Errors
throw new HTTP_Exception_404;