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
Firing action on any not "catched" exception.
skaterik
October 2015
Hi;
Maybe this is a more related PHP question than FuelPHP, but i need some help.
The final objective is catching all exceptions not catched for sending an email with the failure info.
I decided to put the following code block in the index.php:
//--- Fragment of index.php (starting in Line 85)
// Generate the request, execute it and send the output.
try
{
// Boot the app...
require APPPATH.'bootstrap.php';
// ... and execute the main request
$response = $routerequest();
}
catch (HttpNoAccessException $e)
{
$response = $routerequest('_403_', $e);
}
catch (HttpNotFoundException $e)
{
$response = $routerequest('_404_', $e);
}
catch (HttpServerErrorException $e)
{
$response = $routerequest('_500_', $e);
}
/* ADDED CODE HERE*/
catch(Exception $e)
{
SomeClass::SomeMethod();
}
//-- End of fragment
I do not know if this is the best way to do what I want, or is there another more elegant.
Harro
October 2015
Accepted Answer
That is an option.
But if you want to know what the app is doing, it's perhaps better to attach a mail handler to the log and have it email log entries (for example all warnings or errors).
See this post on how to setup a custom log handler:
http://fuelphp.com/forums/discussion/13671/is-it-possible-to-log-to-database
skaterik
October 2015
Thanks harro
:)
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,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
October 2015
skaterik
October 2015