Fix #112: pass exception handling on fatal errors properly

This commit is contained in:
Denis Sokolov
2013-11-14 21:07:07 +01:00
parent ab1b5b8848
commit 63b136a2c4
+18 -1
View File
@@ -326,7 +326,13 @@ class Run
return true;
}
}
throw new ErrorException($message, $level, 0, $file, $line);
$exception = new ErrorException($message, $level, 0, $file, $line);
if ($this->canThrowExceptions) {
throw $exception;
} else {
$this->handleException($exception);
}
}
}
@@ -335,6 +341,11 @@ class Run
*/
public function handleShutdown()
{
// If we reached this step, we are in shutdown handler.
// An exception thrown in a shutdown handler will not be propagated
// to the exception handler. Pass that information along.
$this->canThrowExceptions = false;
$error = error_get_last();
if ($error && $this->isLevelFatal($error['type'])) {
$this->handleError(
@@ -346,6 +357,12 @@ class Run
}
}
/**
* In certain scenarios, like in shutdown handler, we can not throw exceptions
* @var boolean
*/
private $canThrowExceptions = true;
private static function isLevelFatal($level)
{
return in_array(