I'm using Phil Sturgeon's REST_Controller in CodeIgniter, but I would like to use try...catch blocks in a way more familiar to an old Java programmer like myself. So, I added a function to Phil's controller:
function exception_error_handler($errno, $errstr, $errfile, $errline, $errcontext){
$ee = new ErrorException($errstr, 0, $errno, $errfile, $errline, $previous);
throw $ee;
}
Then in the __construct
method of the controller, I tried to connect that function up with error handling:
set_error_handler("exception_error_handler");
When I now run a controller that extends REST_Controller, I get this error message:
set_error_handler() expects the argument (exception_error_handler) to be a valid callback
If I put the function and the call set_error_handler in the sub-class, there is no error and my try...catch blocks catch the exception whenever there is an error. Why isn't my callback valid in the super class?