Welcome Guest, Not a member yet? Register   Sign In
Can't catch exception in my own code, instead exception is handled in Codeigniter
#1

[eluser]Unknown[/eluser]
I'm relatively new with Codeigniter but I don't seem to be able to catch an exception when processing a controller request, triggered by an Ajax HttpRequest.
My code looks like this:

Code:
//
// Some other code here ...
//
// Initiate stream connection to $uri (socket timeout = 2 seconds)
$fp = NULL;
try
{
  $fp = stream_socket_client($uri, $errno, $errstr, 2);
}
catch (Exception $error_string)
{
  logError($error_string);
}
if ( fp )
{
  // do something
}

When I force a condition where the stream connection fails, it looks like an exception is thrown, but instead of 'receiving' the exception in my own code it is handled inside the Codeigniter framework, in particular in exceptions.php, resulting in show_php_error() being called.

This returns a lot of HTML-encoded error texts in the Ajax POST response, which I of course wanted to avoid by catching the exception myself.

Any idea what I am missing or forgetting here?

Thanks for any feedback.
Jos
#2

[eluser]PERR0_HUNTER[/eluser]
Same problem here, I think it has to do with set_error_handler() from PHP, since it's a php5 function and CI is designed to still work with PHP4 it overrides the way errors are handled :S




Theme © iAndrew 2016 - Forum software by © MyBB