Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Errors Handling
mayismile
August 2013
Hello,
How can I handle 500 error on PRODUCTION environment? For example, if I want to write errors to file.
Thanks
Harro
August 2013
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.
mayismile
August 2013
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?
Harro
August 2013
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.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
August 2013
mayismile
August 2013