On Oct 10, 2006, at 2:58 PM, KMiller wrote:

Not for a production environment though. I was trying to come up with a way to hide the details from the user and simply display "an application error has occured - support has been notified" sort of thing, log the errors, and then allow the user to continue with what they were doing (assuming they could still do other useful things). My confusion is around how to have the
handler break out of the front controller loop from deep within the
application if I hit an uncaught exception.  I thought of having an
ErrorController to handle things but not sure how to call it at the right
time.

You don't have to worry about how to break out of the controller loop. An exception will propagate all the way up the call chain until it is (or isn't) handled. For such "out of left field" errors, I have something like this in my index.php file (in pseudo-code):

try {
        $controller->dispatch();
} catch (Exception $e) {
        // load or create a simple error page
        // send it to the user
        // log exception details to a text file
        // send e-mail?
        // hope it doesn't happen again :-)
}

At this point, I generally revert back to plain-old procedural PHP code instead of an ErrorController, as I can't be sure if the framework itself is broken.

--

Willie Alberty, Owner
Spenlen Media
[EMAIL PROTECTED]

http://www.spenlen.com/

Reply via email to