Hi,
What's the best way to extend error handling in fuel? I want to extend it so I can capture all the errors that happened in the system them send them via email
Many thanks,
CJ
Adding the ability to email errors for production is also on my "to do" list. I did that for CodeIgniter. I'd also be interested in hearing any suggestions on the best way to do it.
The log file is useful, but I'd like to include the backtrace. Often, the actual error reported doesn't indicate where the real problem is. Emailing the error along with the backtrace has been really useful in debugging problems on live websites.
I've briefly gone through the error class and see there's a function show_production_error() which seems like an obvious function to overload and generate an email. Unfortunately, all the functions that call show_production_error() would also have to be overloaded because they don't pass the error information. Is there any chance of adding the error information as a parameter to show_production_error()?
show_production_error() is to far in the process. It is called when it is determined that your configuration states that error messages should not be displayed.
Whether to call show_production_error() or show_php_error() is determined in the shutdown_handler(), which also has information about the error that ocurred.
So the logical thing to do is to replace this method in your class extension.
You also need to replace the exception_handler, as the first one only captures PHP errors, and no exceptions.