PHP exceptions thrown in error handler are not caught by exception handler
<p>I use the following function to set my own error handler and exception handler.</p>

<pre><code>set_error_handler
set_exception_handler
</code></pre>

<p>The error handler transforms errors to exception. (throws a new exception)</p>

<p>But these exceptions are not caught by my own exception handler.</p>

<p>error handler example:</p>

<pre><code>function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) {
   throw new Exception("this was an error");
}
</code></pre>

<p>exception handler example:</p>

<pre><code>function exceptionHandler($e){
   // don't get here when exception is thrown in error handler
   Logger::logException($e); 
}
</code></pre>

<p>(I think this can not work anyway)</p>

<p>Should this work ?</p>

<p>Or can someone explain why it can not work ?</p>

<p>EDIT:</p>

<p>I made some tests, and it should work. </p>

<p>Exceptions thrown in the ErrorHandler are getting caught by the ExceptionHandler 
And Errors triggered in the ExceptionHandler are getting processed by the ErrorHandler </p>

<p>Just FYI.</p>

<p>My Problem has to be elsewhere</p>

<hr>

<p>EDIT:</p>

<p>I Still have not found why the exception thrown in my errorHandler is not caught by my exceptionHandler.</p>

<p>For Example when I have this somewhere in the code.</p>

<pre><code>trigger_error("this is an error"); // gets handled by the errorHandler
throw new Exception("this is an exception"); // gets handler by the exceptionHandler
</code></pre>

<p>The error gets handled by the errorHandler but the exception thrown in the errorHandler gets not handled by the exceptionHandler.</p>

<p>But if I throw an exception at the same place where I trigger an error, this exception gets handled by the exception handler. </p>

<p>(Hope it is somehow understandable what I mean)</p>

<p>I'm clueless here.
Any Ideas where I have to look for the Problem?</p>
