CodeIgniter Forums
try catch being ignored - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: try catch being ignored (/showthread.php?tid=46374)



try catch being ignored - El Forum - 10-29-2011

[eluser]Unknown[/eluser]
Excuse me if this is covered elsewhere. I did a cursory search and could not find a reference to the problem I am having.

I have code wrapped in a try/catch block and notied that codeigniter is catching and handling errors before they have a chance to get to my catch.

For instance, I have the following test case:

try
{
list($a,$b) = explode(',','testss');
}
catch (Exception $e)
{
log_message('error', "got error");
return;
}

It throws an error as there is only 1 return value and hence nothing for $b. The problem is, my catch handler is not being hit. Instead, CI throws up the error notice on my page and php keeps chugging. This causes problems for me as I cannot depend on my catch's being called and terminating processing.

The message CI puts up is:

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 1

Filename: controllers/form_define.php

Line Number: 9



Do I just have a flag turned on somewhere that is causing this? Can I disable this behavior?