CodeIgniter Forums

Full Version: Error messages in Production
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey CodeIgniter Forums!

Wasn't 100% sure where to post this, so I'm going to try here.

I'm about to roll an application out to production that a few people have been working on for a while, and we're just doing the last of the testing. When in a production mode, there are no PHP errors shown, which is good, but if an error in encountered in the PHP, it just shows a blank page. Now I know the goal is that in production you wouldn't have any php errors, but things happen and sometime you've just missed something.

The problem with a blank page is the user has no idea what has happened, for all they know, it could be a problem on their end. Is there anyway to have a view defined for errors that happen in production? that way I could provide a message to the user that says "oops, we've had a problem" and a link back to the homepage?

I've been looking around google for a while and haven't found anything like this. Any help or just a point in the right direction would be much appreciated.

Thanks
There are views included for most types of errors in `/application/views/errors/`, but one of the best ways to do this would be to catch and handle the errors before they end up in CI's error/exception handlers (or suppress the errors with @ if you can check for the error conditions in your code).

If you're having trouble with errors in a specific location in your code, you could always precede that code with a call to set_error_handler(yourErrorHandler) and follow it with restore_error_handler() to restore CI's error handler.