views:

786

answers:

1

I've been wondering what's the best way to deal with exceptions on CodeIgniter. The usual way is to use triger_error() or log_message() ... however I've been wondering if there's a better way using try/catch.

Any tips or recommendations on how to implement this into CodeIgniter?

Currently I'm extending the Exceptions class, but I would like to know if someone else already dealt with this problem before.

+1  A: 

I would do something as simple as:

try { $this->load->model('modelname'); }

catch ( Exception $e )
{
    show_error($e);
}

If you application is environment aware then I would show_error() on local, email error on live. This functionality could even be added into MY_Model to work generically for all models.

Phil Sturgeon