I use the following function to set my own error handler and exception handler.
set_error_handler
set_exception_handler
The error handler transforms errors to exception. (throws a new exception)
But these exceptions are not caught by my own exception handler.
error handler example:
function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) {
throw new Exception("this was an error");
}
exception handler example:
function exceptionHandler($e){
// don't get here when exception is thrown in error handler
Logger::logException($e);
}
(I think this can not work anyway)
Should this work ?
Or can someone explain why it can not work ?
EDIT:
I made some tests, and it should work.
Exceptions thrown in the ErrorHandler are getting caught by the ExceptionHandler And Errors triggered in the ExceptionHandler are getting processed by the ErrorHandler
Just FYI.
My Problem has to be elsewhere
EDIT:
I Still have not found why the exception thrown in my errorHandler is not caught by my exceptionHandler.
For Example when I have this somewhere in the code.
trigger_error("this is an error"); // gets handled by the errorHandler
throw new Exception("this is an exception"); // gets handler by the exceptionHandler
The error gets handled by the errorHandler but the exception thrown in the errorHandler gets not handled by the exceptionHandler.
But if I throw an exception at the same place where I trigger an error, this exception gets handled by the exception handler.
(Hope it is somehow understandable what I mean)
I'm clueless here. Any Ideas where I have to look for the Problem?