(1-1/1)
What happens if you just catch all exceptions in your controller? (I'm not suggesting this as a solution, but it'd be useful to figure out if any exceptions at all are being thrown):
try { $this->view_data['test'] = Cohort::find(1); } catch (Exception $e) { echo $e->getMessage(); }
(1-1/1)
June 27 2010
April 16, 2013
Subject: Problems with error handling
I am working on a codeigniter 2 project with php-activerecord models. I am having troubles with some models and I can't seem to find a way to catch errors before they crash my application. Here is a test example:
My Model looks like this:
My controller function does this:
I have also tried this:
This works if Cohort::find(1) returns a result, which is the case if I comment out the association. However, something in my association breaks the query, but that's not my question. My question is why does the try...catch block not catch an exception? Whatever I do, an invalid query seems to immediately break my application and return a blank screen. Can anybody help?
PHP is version 5.3.6 and error reporting is turned on (and works for most other php errors).