Question

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

  1. the error is being detected
  2. the exception is being handled

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. I've also found out that there is a major revamp from KO 3.0 to 3.1 how about KO 3.2? Thank you for your help guys :)

Was it helpful?

Solution

From the kohana source-code.

- > 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. 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

OTHER TIPS

here is how I do it with Kohana 3.2

  • Add exceptions handling stuff in index.php
    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();
  • Then write Errors controller
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)

  • 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

  • Now every time you throws the exception in your controller, it will display the custom error page, like this
throw new HTTP_Exception_404;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top