snytkine / LampCMS

Open source Question and Answer program similar to StackOverflow and Quora in PHP + MongoDB. Follow @snytkine on Twitter

Home Page:http://support.lampcms.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Centralize error handler and exception handler

snytkine opened this issue · comments

Create a new file errorHandler.php place in the Lampcms dir
Require this file from !inc.php
It will have ErrorHandler function
and ExceptionHandler function
then it will register these functions as default error handler
and default exception handler

Then try to do away with the try/catch block in index.php and have the default exception handler catch all uncaught exceptions
and email admin on errors.

Inside ExceptionHandler always try to use Mailer class first inside try/catch the inside the catch block
fallback to mail() function.

This way we can still attempt to use SwiftMailer for error emails but it that does not work then fallback to php's mail()

Current error handler was modified. Major rewrite is not necessary for this release may revisit this possibility in some future releases.