Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Errors Handling
  • Hello,

    How can I handle 500 error on PRODUCTION environment? For example, if I want to write errors to file.

    Thanks
  • To trigger a 500 error, use

    throw new \HttpServerErrorException();

    To handle it, catch it in your index.php, the same way the 404 is caught, and issue a new request to a controller method that handles your 500 error.
  • Oh, yes. But I've meant 500 that was generated by server. I think I should add some code to this function at core error.php

    public static function show_production_error(\Exception $e)
    {
    // when we're on CLI, always show the php error
    if (\Fuel::$is_cli)
    {
    return static::show_php_error($e);
    }

    if ( ! headers_sent())
    {
    $protocol = \Input::server('SERVER_PROTOCOL') ? \Input::server('SERVER_PROTOCOL') : 'HTTP/1.1';
    header($protocol.' 500 Internal Server Error');
    }
    exit(\View::forge('errors'.DS.'production'));
    }

    Or it can be done outside of the core? 
  • If the 500 was generated by your webserver, Fuel doesn't come into play (you have a server error, PHP isn't even loaded), so I'm not sure what you're on about.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion