[Debug] Reset previous exception handler ealier to prevent infinite loop
This commit is contained in:
parent
ffd088a38f
commit
f7e1bb05e2
@ -544,15 +544,16 @@ class ErrorHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$exceptionHandler = $this->exceptionHandler;
|
||||||
|
$this->exceptionHandler = null;
|
||||||
try {
|
try {
|
||||||
if (null !== $this->exceptionHandler) {
|
if (null !== $exceptionHandler) {
|
||||||
return \call_user_func($this->exceptionHandler, $exception);
|
return \call_user_func($exceptionHandler, $exception);
|
||||||
}
|
}
|
||||||
$handlerException = $handlerException ?: $exception;
|
$handlerException = $handlerException ?: $exception;
|
||||||
} catch (\Exception $handlerException) {
|
} catch (\Exception $handlerException) {
|
||||||
} catch (\Throwable $handlerException) {
|
} catch (\Throwable $handlerException) {
|
||||||
}
|
}
|
||||||
$this->exceptionHandler = null;
|
|
||||||
if ($exception === $handlerException) {
|
if ($exception === $handlerException) {
|
||||||
self::$reservedMemory = null; // Disable the fatal error handler
|
self::$reservedMemory = null; // Disable the fatal error handler
|
||||||
throw $exception; // Give back $exception to the native handler
|
throw $exception; // Give back $exception to the native handler
|
||||||
|
@ -530,4 +530,17 @@ class ErrorHandlerTest extends TestCase
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Exception
|
||||||
|
*/
|
||||||
|
public function testCustomExceptionHandler()
|
||||||
|
{
|
||||||
|
$handler = new ErrorHandler();
|
||||||
|
$handler->setExceptionHandler(function ($e) use ($handler) {
|
||||||
|
$handler->handleException($e);
|
||||||
|
});
|
||||||
|
|
||||||
|
$handler->handleException(new \Exception());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user